Allocators

Allocators are opaque objects that allocate, reallocate, and deallocate memory for Core Foundation objects. They are associated with the object throughout its life span. You pass references to allocators in Core Foundation functions that create objects. Core Foundation provides a per-thread default allocator and a system allocator that you can use for most purposes.

However, Core Foundation allows you to create your own custom allocators, which might be necessary in rare cases. The CFAllocator opaque type (defined in CFBase.h ) provides programmatic interfaces for allocator creation. To define a custom allocator you must specify callback functions that allocate memory, deallocate memory, and so on. See Creating Custom Allocators for more information.

Once you have created a custom allocator you can set it as the system default with the CFAllocatorSetDefault function. You can also use the allocators of existing Core Foundation objects in the creation of new objects. This technique effectively performs memory "zoning."

See "The Role of Allocators in Object Creation" in the chapter "Overview of Core Foundation" for more information on allocators.


© 1999 Apple Computer, Inc. – (Last Updated 07 September 99)