Hi NXP community,
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x00001000;
This heap memory allocation is defined in SRAM area using linker script.
Can anyone tell me the above mentioned heap is used by standard library or not, Like malloc, calloc and free?
Solved! Go to Solution.
@vignesh3 , yes the C runtime will use this heap region to serve the dynamically allocated memory requests. the heap is initialized in the startup code. The linker defines the heap size with the variable named HEAP_SIZE.
malloc uses _sbrk function.
_sbrk uses the variables such as __heap_limit defined in the linker. That's how the dynamically allocated memory is defined and used.
Hope this helps!
@vignesh3 , yes the C runtime will use this heap region to serve the dynamically allocated memory requests. the heap is initialized in the startup code. The linker defines the heap size with the variable named HEAP_SIZE.
malloc uses _sbrk function.
_sbrk uses the variables such as __heap_limit defined in the linker. That's how the dynamically allocated memory is defined and used.
Hope this helps!
Hi @gaurav_sharma ,
_sbrk is for allocating the memory right?
If it is like this where can it get free?
Thanks for the reply.
@vignesh3 , yes _sbrk is a function used by malloc() to increment 'heap_end' and returns a pointer. So it allocates memory in that sense.
Using the function 'free()', the memory gets freed per se. This means that this function marks this memory as available for re-use.