|
||
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.
The API has two key concepts: chunk and heap.
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:
a chunk that contains:
the process executable's .data
section
(initialised global and writable static data)
the process executable's .bss
section (zero
filled data)
user-side stack space for all threads that run in that process.
a chunk to contain the heap used by the main thread of the process.
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.
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:
monitored for memory leaks: this happens automatically for GUI applications
shared between threads within a process
accessed and manipulated at the cell level
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.