MCUXpresso heap handling

Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCUXpresso heap handling

Contributor II

Hello everyone, i noted a different mode of handle memory heap region between KDS and MCUxpresso. For example I created two identical project for k64k uC one with KDS and the other with #MCUxpresso leaving the same default heap dimension (eg 0x400 for k64f uC) with booth the ide. At run time when call a dinamic allocation function as malloc and try to allocate a memory area with dimensione greater then heap region, with #KDS the uC run without problem and malloc return a right pointer while with MCUxpresso the function return a null pointer. Can someone explane me what are the difference between the two #heap handling ?

Labels (1)
0 Kudos
1 Reply

NXP Employee
NXP Employee

I can't talk for KDS behaviour, but if the heap allocator finds that there is insufficient space left in the heap area, then you should get a NULL back from malloc(): 

Your code should then take the appropriate action after checking for the NULL being returned.

For details of how to modify the amount of space reserved for the heap, please read the MCUXpresso IDE v10.1.0 User Guide, chapter 14, " Memory Configuration and Linker Scripts" - in particular section 14.9, "More advanced heap/stack placement".


MCUXpresso IDE Support

0 Kudos