TAP_MemInfo

Topfield Documentation

void TAP_MemInfo(dword *heapSize, dword *freeHeapSize, dword *availHeapSize)

It finds the usable HEAP information.

  • heapSize : total HEAP size
  • freeHeapSize : free HEAP size
  • availHeapSize : available HEAP size

Additional Documentation

The difference between Free and Available

Malloc will normally allocate memory in chunks; so if you ask for 1 byte, it may actually allocate 100 bytes. Malloc also has to keep track of all the used/unused blocks, and it is not obliged to return freed blocks immediately - it may hang on to some smaller blocks to avoid fragmenting the ram too much, and to keep its lists reasonably small.

The free size is the total unused ram, including the unreachable parts, the available ram is amount that you can actually use.

  • you should use the available value, as this is always lower than the free size.
  • but the available ram may be fragmented, so you will probably not be able to malloc a block of available size; so always check the return value, rather than as the topfield api suggests, by calling TAP_MemInfo()