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

when do i need (have to) to use nrf memory manager and when i can use malloc\calloc\free

Hi.

I'm using nrf52840 SDK 16 with S140.

in my last piece of code static arrays were not enough and i needed malloc.

I used malloc without any issue, also i use cJSON and it uses malloc as well. again with no issue as far as i can see.
However my CTO used our prohject with small modification to work with free_rtos and had hardfaults, apparently after changing to memory manager with nrf_malloc\nrf_free his hardfaults were over.

This brings me to the question when should i use memory manager, why should i use it at all (is it that better in preventing fragmentation) ?

Also considering that i want to use dynamic memory to save on ram space (i don't want to define static array size of X (where each element is sizeof(my_struct)) when i can dynamically allocate an array size of y where y < x is it worth the risk in most cases ? (yeah i know this is more philosophical than an actual deterministic question)

Parents
  • Thanks for the reply.

    My query was more to understand when should i use the nordic memmory manager instead of libc malloc that arrived with the armgcc toolchain (that comes with segger studio). From looking at the sources they do pretty much the same only you have less control of the heap configuration.

    So is that the big advantage of the nordic memory manager ? the heap configuration ?

Reply
  • Thanks for the reply.

    My query was more to understand when should i use the nordic memmory manager instead of libc malloc that arrived with the armgcc toolchain (that comes with segger studio). From looking at the sources they do pretty much the same only you have less control of the heap configuration.

    So is that the big advantage of the nordic memory manager ? the heap configuration ?

Children
Related