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().
Hi Giussepe,
You can find more information about the libraries that come with MCUXpresso on the chapter 13. "C/C++ Library Support" in the MCUXpresso user guide, you can chose the one that fits better for your application based on their differences.
About the Newlib implementation of malloc, I'm not sure how it was implemented but newlib is open source and you can find more information on this link:
Hope it helps!
Best Regards,
Carlos Mendoza
Technical Support Engineer
Thank you carlosmendoza for your answer.
Another question. How to monitor the heap usage during runtime? How to find the heap usage space, free space, and so on?