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++

From Wiki
Jump to: navigation, search

Article Metadata
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
Created: User:Technical writer 2 (30 Nov 2006)
Last edited: hamishwillee (14 Jun 2012)


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);
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 ...

This page was last modified on 14 June 2012, at 07:16.
49 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.