Functionality Common to the Different Types of Heaps

This section describes the functionality common among the expanded, frame, and unit heap.

Heap Options

Among the functions that can be used to create a heap, heap options can be specified using MEMCreateExpHeapEx, MEMCreateFrmHeapEx and MEMCreateUnitHeapEx. The following are options that can be specified.

Options That Can Be Specified During Heap Creation
FlagContent
MEM_HEAP_OPT_0_CLEARThe allocated memory block is filled with zeroes upon allocation from the heap.
MEM_HEAP_OPT_DEBUG_FILLWhen a heap is created and memory blocks are allocated and deallocated, this fills the memory regions respectively with different 32-bit values.
MEM_HEAP_OPT_THREAD_SAFEEnables exclusive processing between threads.

The MEM_HEAP_OPT_DEBUG_FILL flag is used for debugging. Use this flag to find memory access bugs by tracing the pointer that points to the memory initialization failure or invalid memory regions. This flag will not function in the final ROM (FINALROM) version of the library. The following values fill in memory regions by default. See the next section to learn how to change these values.

Changing Fill Values for Debugging

By specifying the MEM_HEAP_OPT_DEBUG_FILL flag when creating the heap, the memory region can be filled with a different 32-bit value during heap creation, memory block allocation and deallocation, respectively. This fill value can be modified. You can set and get the fill values using the following functions.

Functions for Setting and Getting Debug Fill Values
FunctionsFeatures
MEMSetFillValForHeapSets fill values.
MEMGetFillValForHeapGets fill values.

Different values can be set when heaps are created, memory blocks are allocated, and memory blocks are freed. When you set or get values, the heap operation the values are specific to is set. The following table shows the types of heap operations specified in the function.

Types of Heap Operations for Fill Values
Value Specified in the FunctionHeap Operation
MEM_HEAP_FILL_NOUSEAt heap creation.
MEM_HEAP_FILL_ALLOCAt memory block allocation.
MEM_HEAP_FILL_FREEAt memory block freeing.

Displaying Heap Content

This feature for displaying the content of the heap is for debugging. The following functions accomplish this.

Functions that Display Internal Heap Data
FunctionsFeatures
MEMDumpHeapDisplays internal heap data.

Getting Heap Regions

This feature obtains the start and end address of memory regions used by the heaps. The following functions accomplish this.

Functions for Getting the Heap Region
FunctionsFeatures
MEMGetHeapStartAddressGets the starting address of the memory region used by the heap.
MEMGetHeapEndAddressGets the ending address + 1 of the memory region used by the heap.

Revision History

2013-05-08 Automated cleanup pass.
2010-11-01 Initial version.


CONFIDENTIAL