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.
对于本文的一些评论:
1.chenziteng- I bet .mmp file is a better place to specify the max heap size for an application, google EPOCHEAPSIZE for more details.
- 2007-6-20 23:29:10
本文介绍了一种方法,即如何将应用程序的默认堆内存大小从1MB增加到更大的容量,例如2MB,这对于需要处理大量数据的应用如图像处理非常有用。通过使用自定义堆替代默认堆,可以在目标设备上为应用程序分配更多内存。
8907

被折叠的 条评论
为什么被折叠?



