×
Namespaces

Variants
Actions

Allocating memory cells from a non-default heap using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search



Article Metadata
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition (initial release)
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 ...
    }
}

This page was last modified on 14 June 2012, at 10:16.
42 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.

×