[Previous] [Up] [Next]

NSAutoreleasePool

Authors

Richard Frith-Macdonald

Version: $Revision$

Date: $Date$

NSAutoreleasePool

NSAutoreleasePool

Declared in: Foundation/NSAutoreleasePool.h

Inherits from: NSObject

Conforms to: NSObject


This class maintains a stack of autorelease pools objects in each thread.

When an autorelease pool is created, it is automatically added to the stack of pools in the thread.

When a pool is destroyed, it (and any pool later in the stack) is removed from the stack.

Instance Variables

Methods


Class Methods

addObject:

+ (void) addObject: (id)anObject;

Adds the specified object to the current autorelease pool. If there is no autorelease pool in the thread, a warning is logged.


enableRelease:

+ (void) enableRelease: (BOOL)flag;
Standards: GNUstep NotMacOS-X NotOpenStep

Specifies whether objects contained in autorelease pools are to be released when the pools are deallocated (by default YES).

You can set this to NO for debugging purposes.


autoreleaseCountForObject:

+ (unsigned) autoreleaseCountForObject: (id)anObject;
Standards: GNUstep NotMacOS-X NotOpenStep

Counts the number of times that the specified object occurs in autorelease pools in the current thread.

This method is slow and should probably only be used for debugging purposes.


freeCache

+ (void) freeCache;
Standards: GNUstep NotMacOS-X NotOpenStep

When autorelease pools are deallocated, the memory they used is retained in a cache for re-use so that new polls can be created very quickly.

This method may be used to empty that cache, ensuring that the minimum memory is used by the application.


setPoolCountThreshold:

+ (void) setPoolCountThreshold: (unsigned)c;
Standards: GNUstep NotMacOS-X NotOpenStep

Specifies a limit to the number of objects that may be added to an autorelease pool. When this limit is reached an exception is raised.

You can set this to a smallish value to catch problems with code that autoreleases too many objects to operate efficiently.

Default value is maxint.



Instances Methods

addObject:

- (void) addObject: (id)anObject;

Adds the specified object to this autorelease pool.