This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Finding the heap low water mark when using nRFConnect/Zephyr

I need to monitor how much heap was ever left available, as a minimum, after I have run my CI test suite.  This is the true minimum heap ever remaining, so taking account of calls to malloc() as well as to Zephyr's memory management APIs, i.e. the true underlying heap low water mark.

I could do this on NRF52 as I had the implementation of _sbrk() that FreeRTOS called into (the Dave Nadler one).

What is the equivalent in the nRFConnect/Zephyr world on NRF53?

Rob

Parents Reply
  • We have stack sorted (we call k_thread_stack_space_get()), it's heap that we can't measure.

    I had thought that it would be possible to do a maximum heap extent measurement by simply monitoring newlib's calls to sbrk(), since newlib will not ask for more space until it needs it.  But it might be that newlib calls for more space irrespective of whether there might be a free'd block it could use, deliberating putting off the freeing process as an expensive operation.

    So yes, if you were able to devise a mechanism to monitor heap I would be very interested.

Children
Related