Introduction
The RH850 Family cores have one continuous 4 Gbytes memory space. 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.
The compiler can access memory in different ways. The access methods range from generic but expensive methods that can access the full memory space, to a cheap method that can access the limited address memory area. For more information about this, see Memory types.
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. For more information, see Data models and Memory types.
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.