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

HEAP_MEM_POOL_SIZE > 16384 on nrf9160

Hi,

Is it possible to set CONFIG_HEAP_MEM_POOL_SIZE to be more than 16384?

I try to configure CONFIG_HEAP_MEM_POOL_SIZE = 94208 and when the heap allocated until 36830 bytes the k_malloc() returns NULL when I try to allocate 528 bytes.

I added some codes on k_malloc() and k_free() to keep track of the memory allocation as shown below:

/***************************************************************/

[k_mem_pool_alloc] z_sys_mem_pool_block_alloc() return -12
p->base.max_sz=94208, size=528
[k_mem_pool_malloc] k_mem_pool_alloc() fail
[k_malloc] alloc fail (528 byte), total_alloc=36830 

/***************************************************************/

"total_alloc" store the current total heap memory allocated to the app.

Parents
  • As an awkward workaround, you can define multiple memory pools of size 16384, then create replacement malloc/free functions which try to malloc from each in turn and ensure that frees go back to the pool they came from.

    You still won't be able to allocate anything bigger than either 2K or 4K since that's the single biggest allocation from any one pool, though.

Reply
  • As an awkward workaround, you can define multiple memory pools of size 16384, then create replacement malloc/free functions which try to malloc from each in turn and ensure that frees go back to the pool they came from.

    You still won't be able to allocate anything bigger than either 2K or 4K since that's the single biggest allocation from any one pool, though.

Children
No Data
Related