Heap usage monitoring

Rob Meades

I have a question about heap usage monitoring.  Apologies if this is the wrong place to ask, please feel free to point me elsewhere if that is the case.

I'm using Zephyr on a Nordic NRF53 chip and 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.  What is the equivalent in the nRFConnect/Zephyr world?  I've asked Nordic (https://devzone.nordicsemi.com/f/nordic-q-a/67495/finding-the-heap-low-water-mark-when-using-nrfconnect-zephyr) but they didn't know the answer immediately and suggested I might ask here instead.

I note that there are heap stress and heap validation functions in sys/sys_heap.c but nothing in there about heap usage. You must have something of this nature to test for memory leaks: can you point me in the right direction please?


Join users@lists.zephyrproject.org to automatically receive all group messages.