GarbageCollector class
The class GarbageCollector implements the garbage collector. It
has the following interface:
@interface GarbageCollector : NSObject + (void)addObject:(id)anObject; + (void)objectWillBeDeallocated:(id)anObject; + (void)collectGarbages; @end
A new garbage collectable object has to be made know to the
GarbageCollector collector by sending it the +addObject:
message with self as argument. When the object is deallocated it should
inform the GarbageCollector class about this by sending it the
+objectWillBeDeallocated: message with self as argument.
The +collectGarbages should be send to the
GarbageCollector class to collect the garbages. You can send it
whenever you want. If you are using a run loop in your program you can
set a timer to be called periodically. Or you can call the garbage
collector when the program is idle.
In the current implementation the garbage collector is not thread-safe, so please don't use it in multi-threaded programs, unless you use garbage collectable objects only in one thread.
Go to the first, previous, next, last section, table of contents.