Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Memory Allocation Overview

[Top]


Purpose

Provides low-level functionality by which a Symbian OS process can access and manipulate memory areas.

Most client programs do not need to use this functionality directly. They are used by programs that are explicitly concerned about sharing memory areas between threads within a process, or between processes.

[Top]


Description

The API has two key concepts: chunk and heap.


Chunk

A chunk defines a contiguous region of virtual addresses. It represents memory that is addressable by running code. A chunk is the fundamental way in which Symbian OS allocates memory and makes it available to running code.

The range of addressable memory is also referred to as reserved memory.

Physical addresses representing either memory storage like RAM, or memory-mapped I/O devices, are mapped into a subset of a chunk's reserved memory. Such memory is said to be committed.

When a process is created, it contains at least two chunks:

If the process executable is loaded into RAM (i.e. it is not ROM resident), then there is another chunk to contain the code.

On ARM processors up to and including those that support the ARMv5 architecture, the memory model used by Symbian OS is the moving memory model. To guarantee real-time behaviour using this model, each process is limited to a maximum of 16 chunks. This means that a program can create up to 14 additional chunks. Where the process executable is loaded into RAM, the chunk containing the code is effectively global and does not contribute to the 16 chunk per process limit.

On ARM processors that support the ARMv6 architecture, the memory model used by Symbian OS is the multiple memory model. Using this model, there is no limit on the number of chunks per process. Where the process executable is loaded into RAM, the chunk containing the code is specific to the process.

TFindChunk is used for finding a global chunk created by another process.

The user-side interface to a chunk is provided by an instance of the RChunk class.


Heap

A heap is used for explicit dynamic allocation of memory. Symbian OS defines C++'s new operator to create objects on the current thread's heap.

Heaps may be:

The heap interface is provided by the RAllocator and MAllocator classes. This interface is abstract so that device manufacturers can implement heaps with different allocation algorithms. Symbian OS provides the RHeap class as a default heap implementation. In practice, there is no need to know about implementation details.

When managing the current thread's heap, it is more convenient to use the equivalent functions provided by the System Static Functions API; this is the User class. For example, User::AllocL(). The System Static Functions API also provides macros that conveniently wrap calls for monitoring heap usage for memory leaks.

[Top]


See also

Raw Memory Overview

System Static Functions Overview

Thread And Process Management Overview