TAP_MemAlloc
Topfield Documentation
void* TAP_MemAlloc(dword size);
allocates the memory at the HEAP.
- size : the memory size to be allocated
- return value : the allocated memory address
CAUTION : This function SHOULD be preceded by the
TAP_MemInfo() to check the memory size.
Additional Documentation
Although Topfield advise checking against the values returned by
TAP_MemInfo, TAP_MemAlloc internally calls TAP_MemInfo and returns 0 if size is greater than availHeapSize-8k.
TAP_MemAlloc allocates memory in blocks of at least 1280 bytes (0x500), so allocating lots of small chunks is will cause excessive memory use.
TAP_MemAlloc and TAP_MemFree seem to be very slow - nearly 1 millisecond for a single Alloc/Free pair on the TF5800. This is 100's of times slower than you'd expect. Consider using dlmalloc/dlfree from the
libcutils? library instead. These implement a heap on top of 64kb blocks allocated from the underlying system and make dynamic memory management on a fine grain level a realistic possibility.
You should call dlmalloc_exit() before TAP_Exit() to release all blocks back to the underlying firmware. You should also consider calling dlmalloc_trim() intermittently to release any unused blocks.