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?
已解决! 转到解答。
@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!
@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.