2 Starting with the release 0.9.0, libFoundation supports the Boehm's
3 garbage collector as an alternative to the standard memory allocation
4 from OpenStep. We consider the new mechanism as a better alternative
5 to the standard way because of its benefits:
7 * the programmer is no longer required to use the
8 -retain/release/autorelease messages, so a source of bugs introduced
9 by the missuse of these methods is removed
11 * the reference counting memory management is unable to properly
12 handle graphs of objects that contain cycles. This is not the case
13 with the Boehm's conservative collector, it automatically eliminates
17 To work with the Boehm's collector several changes were made to the
18 Objective-C runtime. Here is a small description of the changes to the
19 GNU runtime to support the Boehm's collector:
21 * a new member was added to the objc_class, it keeps the type
22 description of each class. This type description is needed because
23 we use the typed memory allocation available in Boehm's collector to
24 maximize the performance and to be able to use the so-called
25 'invisible' pointers (see below).
26 [Be careful to use typed memory with variable sized instances !!!]
28 * defines two new runtime functions, class_get_gc_object_type and
29 class_ivar_set_gcinvisible. The first function provides access to
30 the type descriptor of a class. The second function marks a named
31 instance variable name as invisible to the collector, aka a pointer
32 which is not considered by the collector a reference to a particular
35 * the allocation functions are set up to the the Boehm's collector.
37 Currently only the GNU runtime is supported and I don't think I'll be
38 able to add support for NeXT runtime anytime soon because this support
39 requires access to the runtime sources :-(.
41 The garbage collected library is chosen automatically by the makefile
42 package when you specify the gc=yes flag to the top-level make
43 process, in addition to the rest of the options:
45 $ make debug=yes gc=yes
47 This happens automatically only when you're working with libFoundation
48 in the GNUstep environment. If you're working in the standalone
49 environment, you should add -DLIB_FOUNDATION_BOEHM_GC=1 to the
50 compiler's command line and link against libFoundation_gc.a or
53 The library is installed in a different directory than the normal one,
54 the library combo is extended with one more part that specifies the
55 Boehm's GC. To take advantage of the Boehm's collector, you will need
56 to rebuild all your libraries so that they'll exist in this
57 directory. Other than that you normaly don't have to modify your
58 programs except for optimizing them for the presence of Boehm's
59 collector. libFoundation for example removes out all of the
60 retain/release/autorelease messages sent to objects so that the
61 overhead of sending these messages is completely eliminated.