Instance Method

disableCollectorForPointer:

Specifies that a given pointer will not be collected.

Declaration

- (void)disableCollectorForPointer:(const void *)ptr;

Parameters

ptr

A pointer to the memory that should not be collected.

Discussion

You use this method to ensure that memory at a given address will not be collected. You can use this, for example, to create new root objects:

NSMutableDictionary *globalDictionary;
globalDictionary = [NSMutableDictionary dictionary];
[[NSGarbageCollector defaultCollector]
    disableCollectorForPointer:globalDictionary];

The new dictionary will not be collectable and will persist for the lifetime of the application unless it is subsequently passed as the argument to enableCollectorForPointer:. For more about root objects and scanned memory, see Garbage Collection Programming Guide.

See Also

Manipulating External References

enableCollectorForPointer:

Specifies that a given pointer may be collected.

Deprecated