The Unit Heap Manager allocates only memory blocks with the size that is specified at the time that the unit heap is created. This memory manager is for allocating and freeing memory blocks that have a fixed size. The unit heap does not have a management region for memory blocks which makes the heap more memory efficient. This section provides an overview of the Unit Heap Memory Manager.
To use the Unit Heap Manager, you must create a unit heap. The following functions create and destroy unit heaps.
| Function | Description |
MEMCreateUnitHeap | Creates the unit heap. |
MEMCreateUnitHeapEx | Creates the unit heap. Alignment and heap options can be specified. |
MEMDestroyUnitHeap | Destorys the unit heap. |
The Unit Heap Manager manages the heap regions in chunks of a specified size. Memory block allocation refers to allocating these chunks.
Available chunks are linked as one linked list (free chunk list). The pointer to the next free chunk is placed at the starting address of the chunk. There aren't pointers for in use chunks. (There is also no management region.) When allocating memory blocks, the manager returns the memory block that is linked to the start address of this free chunk list. When freeing a memory block that is in use, the manager links the memory block to the start address of the available chunk list.

| Function | Description |
MEMAllocFromUnitHeap | Allocates a memory block from the unit heap. |
MEMFreeToUnitHeap | Frees a memory block. |
Even though the Unit Heap Manager does not have a memory block management region, the minimum aligment of allocated memory blocks must be on a 4-byte boundary. Allocating a 1-byte memory block consumes 4 bytes of memory.
The Unit Heap Manager can specify the alignment at heap creation. It does not do this for each allocated memory block. All allocated memory blocks will have the same alignment. In the MEMCreateUnitHeapEx function, you can specify 4, 8, 16, or 32 as alignment values. The MEMCreateUnitHeap function does not specify alignment; the alignment value is always a value of 4.
The Unit Heap Manager can get the number of allocatable memory blocks (i.e., the number of free chunks). Shown in the following function.
| Function | Description |
MEMCountFreeBlockForUnitHeap | Returns the number of allocatable memory blocks. |
03/01/2006 Initial version.