Introduction
A 32-bit Arm core can address 4 Gbytes of continuous memory, ranging from 0x0 to 0xFFFF'FFFF. A 64-bit Arm core can address 16 Tbytes of continuous memory, ranging from 0x0 to 0xFFFF'FFFF'FFFF'FFFF. Different types of physical memory can be placed in the memory range. A typical application will have both read-only memory (ROM) and read/write memory (RAM). In addition, some parts of the memory range contain processor control registers and peripheral units.
Different ways to store data
In a typical application, data can be stored in memory in three different ways:
Auto variables
All variables that are local to a function, except those declared static, are stored either in registers or on the stack. These variables can be used as long as the function executes. When the function returns to its caller, the memory space is no longer valid. For more information, see Storage of auto variables and parameters.
Global variables, module-static variables, and local variables declared static
In this case, the memory is allocated once and for all. The word static in this context means that the amount of memory allocated for this kind of variables does not change while the application is running.The Arm core has one single address space and the compiler supports full memory addressing.
An application can allocate data on the heap, where the data remains valid until it is explicitly released back to the system by the application. This type of memory is useful when the number of objects is not known until the application executes.
Note: There are potential risks connected with using dynamically allocated data in systems with a limited amount of memory, or systems that are expected to run for a long time. For more information, see Dynamic memory on the heap.