There is no such function in the rcX BSP. But as the memory allocation relies on standard libc malloc (newlib-1.14 included in Hitex Cross-Compiler Toolchain), there is a possibility to query the underlying functions about memory usage. The total size of the Heap is defined in the LD file and can be calculated manually.
The code below shows how to query the malloc information and check how many heap is left:
extern char _heap_start; /* Defined by the linker */
extern char _heap_end; /* Defined by the linker */
#include
unsigned long GetFreeMemory()
{
/* Total size of the Heap (defined through ld-file) */
unsigned long ulTotalHeapSize = (unsigned long)(&_heap_end - &_heap_start);
struct mallinfo tMemInfo = mallinfo();
/* not yet used heap (max sbrk'able mem) */
unsigned long ulUnallocatedHeap = ulTotalHeapSize - tMemInfo.arena;
/* currently allocated memory inside arena */
unsigned long ulAllocatedMem = tMemInfo.uordblks;
/* Total free memory (ATTENTION: may be partially fragmented inside arena) */
unsigned long ulTotalFree = tMemInfo.fordblks + ulUnallocatedHeap;
M T
Hilscher Gesellschaft für Systemautomation mbH
There is no such function in the rcX BSP. But as the memory allocation relies on standard libc malloc (newlib-1.14 included in Hitex Cross-Compiler Toolchain), there is a possibility to query the underlying functions about memory usage. The total size of the Heap is defined in the LD file and can be calculated manually.
The code below shows how to query the malloc information and check how many heap is left:
Regards
MT