Many types of small data structures are characterized by high allocation and deallocation rates. For these objects, using the normal memory allocation mechanisms can result in a significant performance hit while simultaneously increasing memory fragmentation. To overcome these problems, two macros are provided which will save deallocated objects in a linked list so that they can be re-used without having to actually reallocate memory via malloc() and friends. malloc() is only called when the list of previously freed objects is empty. When defining a new class that uses recycled memory, there are 3 simple steps:
- use the DEFINE_ALLOCATION_LIST macro below in the class declaration
- make sure the class has a 'next' member
- use the DEFINE_ALLOCATION_OPERATORS macro in a source file for the class
To really deallocate the memory currently used in the list of freed objects, call [classname]::deleteFreeList().
Alphabetic index Hierarchy of classes