Hello Support team,
I have an issue with two simultaneous heaps in my project. I use nrf Connect SDK 3.2.2 with the next configuration options:
Hello Support team,
I have an issue with two simultaneous heaps in my project. I use nrf Connect SDK 3.2.2 with the next configuration options:
Hi Priyanka,
Thank you for this answer. I think that the dependency in Kconfig for MCUMGR_GRP_SETTINGS_BUFFER_TYPE_HEAP is not quite correct. It relies on COMMON_LIBC_MALLOC_ARENA_SIZE > 0 condition but in implementation it uses malloc call to allocate the memory and as we see the malloc function does not come from the LibC all the time.
Anyway, any fix for heap allocation in my case needs to carry a local patch for now.
Hello,
I also have a similar situation when working with two heap memory regions in my project.
I'm using a similar SDK and have found that having two heaps concurrently causes a lot of problems, especially regarding memory management. I also want a solution to combine them into a single heap and have memory state monitoring capabilities.
If you find a solution, please share it with me!
Thank you
Hi Emelia,
I managed to do it. I completely removed libc heap, allocated all of the memory for the kernel heap and used the kernel API to monitor it. Here is my config related to it:
CONFIG_SYS_HEAP_RUNTIME_STATS=y CONFIG_SYS_HEAP_INFO=y # Single heap for everything (kernel, Zephyr subsystems, C malloc, C++ new — # see the LIBC section below). Sized to consume most of the free RAM. CONFIG_HEAP_MEM_POOL_SIZE=139264 ### LIBC ### # Disable picolibc's own malloc arena; src/zephyr_malloc_redirect.cpp routes # every allocation entry point (malloc/free/calloc/realloc/reallocarray, # aligned_alloc/memalign/posix_memalign, and aligned C++ new/delete — plain # new/delete resolve to the malloc/free overrides) to the kernel heap, so # HEAP_MEM_POOL_SIZE above is the single heap for everything. CONFIG_PICOLIBC=y CONFIG_COMMON_LIBC_MALLOC=n CONFIG_COMMON_LIBC_CALLOC=n CONFIG_COMMON_LIBC_REALLOCARRAY=n