Reduced library footprint

One method for optimizing a library is to exclude, from the library's export file, those classes that are used internally to that library: classes whose member functions are not used by another library. This process, called trimming the exports, makes libraries smaller (by shrinking the loader section) and their load times faster, it also speeds up the link times of any clients of the libraries.

Trimming a class excludes the member functions of that class from your exports file; only your library can access those functions. Classes in other libraries aren't able to derive from it and data members of that class, and functions in other libraries can't construct objects of that class or call member functions of objects of that class.

NOTE You can hold a pointer to an object whose class was trimmed from the library that exported it, and still be able to call virtual member functions on that object. But you shouldn't, because it is architecturally unsound to do so.

It is possible to make a mistake, to trim too much. If you trim a class that another library needs, the link process fails when you try to build the client. It's also possible to trim too much and not learn about it. For example, you might trim a class that isn't used by any current clients but that might be used by future clients, or clients which are produced by other developers. You wouldn't learn about that problem until the (distant) client tries to build against your library and fails. Even inlines can get you in trouble; an inline that uses a class means any code that uses the inline is a client of the class. So be careful, and trim only classes used internally by your library.

To trim exports, use the CreateMake trimexports: tag in your *.PinkMake. For example, to exclude TMyClass and TMyStudentClass:

      trimexports:
          TMyClass
          TMyStudentClass
You can also use the TrimExports tool, but that is extra work. See
"TrimExports" on page 90 for more information.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker