Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Allocating memory cells from a non-default heap using Symbian C++
S60 3rd Edition (initial release)
Allocating memory cells not from the default heap
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);
void *mallocBuffer = NULL;
TInt size = 8000*1024; //Try to allocate a 8M memory cell
mallocBuffer = pChunkHeap->Alloc(size);
if (mallocBuffer )
//... Use this memory cell ...