|Non-Confidential||PDF version||ARM 100073_0607_00_en|
|Home > The ARM C and C++ Libraries > Stack and heap memory allocation and the ARM C and C++ libraries > Library heap usage requirements of the ARM C and C++ libraries|
Functions such as
malloc() and other dynamic memory allocation functions explicitly allocate memory when used. However, some library functions and mechanisms implicitly allocate memory from the heap.
If heap usage requirements are significant to your code development (for example, you might be developing code for an embedded system with a tiny memory footprint), you must be aware of both implicit and explicit heap requirements.
In C standardlib, implicit heap usage occurs as a result of:
Calling the library function
the first time that an I/O operation is applied to the resulting
Passing command-line arguments into the
The size of heap memory allocated for
80 bytes for the
FILE structure. When the first I/O
operation occurs, and not until the operation occurs, an additional
default of 512 bytes of heap memory is allocated for a buffer associated
with the operation. You can reconfigure the size of this buffer
fclose() is called, the default
80 bytes of memory is kept on a freelist for possible re-use. The
512-byte buffer is freed on
main() to take arguments requires
256 bytes of implicitly allocated memory from the heap. This memory
is never freed because it is required for the duration of
main() must not be declared to
take arguments, so this heap usage requirement only applies to standardlib.
In the standardlib context, it only applies if you have a heap.
The memory sizes quoted might change in future releases.