The default heap size of an application is 1MB, that means on target if you application tried to allocate more than 1MB memory, the allocation will fail. Probably new (ELeave) will leave.
What if you really want your application to allcoate more than 1MB memory? For example, you are developing an image processing application which needs to load big pictures.
There's a way to use a user define heap instead of the default heap, you can do this like:
GLDEF_C TInt E32Main()
{
RHeap *heap = UserHeap::ChunkHeap( NULL, 1024 * 4, 1024 * 1024 * 2 ); // 2MB
if( heap )
{
User::SwitchHeap( heap );
}
TInt ret = EikStart::RunApplication( NewApplication );
if ( heap )
{
heap->Close();
}
return ret;
}
You switch the heap to your own one, which allow you to allocate 2MB in this case
No comments:
Post a Comment