Namespaces
Variants
Actions

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

Jump to: navigation, search



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 ...
    }
}

This page was last modified on 14 June 2012, at 10:16.
176 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved