Using heap listener with default system heap

W Kicinski

How can the heap listener be used with the system heap, that is the k_malloc() and k_free() functions?  It would seem from the documentation that this is possible using HEAP_ID_LIBC.
I took the blinky sample (\zephyr\samples\basic\blinky) and added a low level heap allocator, see in the attached main.c and prj.conf files:
sys_heap_init(&listener_heap, heapmem, 1024);
With that, the heap listener is working.

I then commented out all the code related to creating the low level heap, and switched to using the system heap k_malloc() & k_free().  I changed the listener definition macros HEAP_LISTENER_ALLOC_DEFINE & HEAP_LISTENER_FREE_DEFINE to use HEAP_ID_LIBC.  See the attached files.

The heap listener is not working with the system heap; the listener functions don't get called.  Is there something that is missing in the setup for the heap listener with the system heap in the attached main.c?

Thank you,