S60 3rd Edition
- 描述:
一般来说内存单元是从当前线程堆中分配的,但有时无法这样做,特别当要分配的内存单元很大时。我们可以生成一个新的堆,从它那里获取我们需要的内存单元.
示例如下:
//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 ... }
}