AnsweredAssumed Answered

Heap usage in MCUXpresso

Question asked by Giuseppe Modugno on Feb 9, 2018
Latest reply on Feb 16, 2018 by LPCX presso support

I tried to understand how heap works in MCUXpresso. I read the User Guide and now I'm able to move the location and size of the heap, after changing to MCUXpresso Style for "Heap and Stack placement".

I also understood that the default heap overflow check takes care of the heap size configured in "Managed Linker Script". I tested this behaviour and it seems it works: after some malloc() call, it returns NULL. It seems the size configured in "Managed Linker Script" is taken into account.

 

Now I only want to understand better the mechanism of malloc() under the hood. I'm using "newlib (None)" as Library (I don't know if this is a good choice). What exactly happens when I call malloc()? I can't follow the source code in debug, because the function is in the library, imported as object file.

 

I downloaded newlib 2.4.0 source code (I have MCUXpresso 10.0.2_411) and I'm trying to follow malloc(), malloc_r().

Outcomes