---
title: "disableCollectorForPointer:"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsgarbagecollector/disablecollectorforpointer:"
---

# disableCollectorForPointer:

Specifies that a given pointer will not be collected.

## Declaration

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

## Parameters

- `ptr`: A pointer to the memory that should not be collected.

## Discussion

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:](foundation/nsgarbagecollector/enablecollectorforpointer:.md)
