Atmel CAVR-4 Manual De Usuario
CAVR-4
44
Data segments
AVR® IAR C/C++ Compiler
Reference Guide
THE HEAP
The heap contains dynamic data allocated by use of the C function
malloc
(or one of
its relatives) or the C++ operator
new
.
If your application uses dynamic memory allocation, you should be familiar with the
following:
following:
●
Linker segment used for the heap, which differs between the DLIB and the CLIB
runtime environment
runtime environment
●
Allocating the heap size, which differs depending on which build interface you are
using
using
●
Placing the heap segments in memory.
Heap segments in DLIB
Heaps can be placed in the following memory types:
* The
TINY_HEAP
segment is only available in the Tiny memory model.
To access a heap in a specific memory, use the appropriate memory attribute as a prefix
to the standard functions
to the standard functions
malloc
,
free
,
calloc
, and
realloc
, for example:
_ _near_malloc
If you use any of the standard functions without a prefix, the function will be mapped to
the default memory type near.
the default memory type near.
Each heap will reside in a segment with the name
_HEAP
prefixed by a memory attribute.
For information about how to access a heap in a specific memory using C++, see New
and Delete operators, page 114.
and Delete operators, page 114.
Heap segments in CLIB
The memory allocated to the heap is placed in the segment
HEAP
, which is only included
in the application if dynamic memory allocation is actually used.
Memory type
Segment name
Memory attribute
Tiny
TINY_HEAP
*
_ _tiny
Near
NEAR_HEAP
_ _near
Far
FAR_HEAP
_ _far
Huge
HUGE_HEAP
_ _huge
Table 12: Heaps, memory types, and segments