在Symbian应用程序中增加堆的大小

本文介绍了一种方法,即如何将应用程序的默认堆内存大小从1MB增加到更大的容量,例如2MB,这对于需要处理大量数据的应用如图像处理非常有用。通过使用自定义堆替代默认堆,可以在目标设备上为应用程序分配更多内存。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Increase the heap size of an application

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.

对于本文的一些评论:

  • quote 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
  • quote 2.Jimmy
  •  
  • Yes, use EPOCHEAPSIZE in the .mmp file makes sense, but it's only for target, in emulator, it seems it doesn't work. Thanks.
  • 2007-6-21 9:31:49
转载自:http://www.symbian.net.cn/blog/post/16.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值