The main thread of a process has a memory chunk that contains the thread's heap. A program's request for memory is allocated from this heap.
Each thread has a chunk which contains that thread's program stack. For the main thread of a process, this chunk also contains the thread's heap. A program's request for memory is allocated from this heap. For example, a code fragment such as:
causes a portion of memory to be allocated from the heap and its address returned to the caller. Memory from the heap must be explicitly requested and, importantly, explicitly freed by the program.
If a process creates additional threads, then a new chunk is created for each new thread. Each chunk contains the thread's stack; if a new thread is not sharing an existing heap, then the chunk also contains a new heap.
When a new thread is created, either:
a new heap is created for it
it uses the creating thread's heap
it uses an explicitly referenced heap.
A thread gets the handle to its heap by calling User::Heap() .
See Address Space and Process for more background on chunks and heaps.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.