mbed-os-5.10.4: mallinfo() seems to return inaccurate information

11 Dec 2018

mallinfo() seems to return inaccurate information. A call to mallinfo() returns the arena as 3928. It is like mallinfo is pointing to another heap and not the global heap./media/uploads/morrisrx/mallinfo.png

I'm running an STM32F767ZI and the heap as reported by mbed_heap_size is 510808 Bytes. I can allocate objects that are hundreds of Kbytes, so this seems reasonable.

What needs to happen to have mallinfo() correctly report the global heap size, usage, etc.?

Thanks

13 Mar 2019

Hi Richard,

Please note two things:

  • Using GCC or Arm Compiler, the heap will grow as a result of _sbrk() call, which happens internally in malloc()
  • mbed_heap_size is calculated from linker result, and is the maximum size the heap can grow to.

So if you run a code that does more allocations, you will notice that arena size should rise accordingly.

Please log in to post a reply.