Free List Mechanism
List of: Discussion Topic
Subjects: Memory Management
Contents: Base

When a new block of memory is needed, it is allocated from the system and added to the appropriate free list. ACIS free list objects allocate 4KB blocks of memory, parceled into slots of 16, 32, 48, 64, 96, or 128 bytes respectively, as needed. Based on analysis of typical ACIS usage, these six sizes have been determined to be most effective.

For example, when the program requests 50 bytes of memory, the memory manager looks for a slot of the next largest block size, in this case 64 bytes. If an empty 64 byte slot does not currently exist, a 4KB block of memory is allocated from the operating system and added to the 64 byte-sized free list object. Then a pointer to the first free 64 byte slot within that block is returned to the requestor.


Figure 1-1. Free Lists

When the program frees the memory, the corresponding slot within the memory block is marked as unused. When all slots within a given block are marked as unused, the block can either be returned to the operating system or kept and reused. The application has three choices in dealing with unused memory blocks.

Unused blocks can be retained indefinitely. (default) This leads to very fast execution by minimizing the number of operating system allocation requests, but creates a memory footprint that grows without shrinking until program termination.
Unused blocks can be automatically returned to the operating system. This yields a small and dynamic memory footprint for ACIS, but may result in more (slower) allocations from the operating system as memory is requested.
The application can return unused blocks to the operating system when it chooses. In this case unused blocks are retained and reused until the application specifically collapses the free lists to return unused memory to the operating system. For example, the application could keep all unused blocks while a model is read in and worked on, thus speeding execution, and then, when done with that model, collapse the free lists and return all now unused memory to the operating system.
PDF/BASE/01CMP.PDF
HTM/DATA/BASE/BASE/01CMP/0012.HTM