Allocating memory cells from a non-default heap using Symbian C++
Article Metadata
Compatibility
Platform(s): S60 3rd Edition
Article
Created: User:Technical writer 2
(30 Nov 2006)
Last edited: hamishwillee
(14 Jun 2012)
Overview
Allocating memory cells not from the default heap
Description
Normally the memory cells are allocated from the current thread's heap but sometimes this is not possible, especially when the size of the memory cell is very large. To create a new heap and allocate a new memory cell from it, follow these instructions:
//Try to create a heap in a local chunk. The minimum length of the heap is 10M and the maximum length is 20M
RHeap *pChunkHeap = UserHeap::ChunkHeap(NULL, 10000*1024, 20000*1024);
if (RHeap)
{
void *mallocBuffer = NULL;
TInt size = 8000*1024; //Try to allocate a 8M memory cell
mallocBuffer = pChunkHeap->Alloc(size);
if (mallocBuffer )
{
//... Use this memory cell ...
}
}

