Detecting Memory Leaks检测内存泄漏

Detecting Memory Leaks
检测内存泄漏


Critical Information
Memory is a limited resource on Symbian OS and must be managed
carefully to ensure it is not wasted by memory leaks. In addition, an
application must gracefully handle any exceptional conditions arising
when memory resources are exhausted. Symbian OS provides a set of
debug-only macros that can be added directly to code to check that
memory is not leaked.
There are a number of macros available, but the most commonly used
are defined as follows:
重要信息

内存是一种有限的资源是基于Symbian操作系统和必须加以管理

小心,以确保它不会被浪费的内存泄漏。此外,

应用程序必须地处理所产生的任何特殊条件

当内存资源枯竭。 Symbian操作系统提供了一套

调试,只有宏,可直接添加到代码检查

记忆是不泄露。

有一些宏,但最常用的

定义如下:

————————————————————————————————————————————————
#define __UHEAP_MARK User::__DbgMarkStart(RHeap::EUser)
#define __UHEAP_MARKEND User::__DbgMarkEnd(RHeap::EUser,0)

————————————————————————————————————————————————
The __UHEAP_MARK and __UHEAP_MARKEND macros verify that
the default user heap is consistent. The check is started by using
__UHEAP_MARK and a subsequent call to __UHEAP_MARKEND performs
the verification. If any heap cells were allocated after the call to
__UHEAP_MARK and then not freed back to the heap before the call to
__UHEAP_MARKEND, a panic will occur in debug builds to indicate that
the heap is inconsistent. The panic raised is ALLOC nnnnnnnn, where
nnnnnnnn is a hexadecimal pointer to the first orphaned heap cell.
The heap-checking macros can be nested inside each other and used
anywhere in code. They are ignored by release builds of Symbian OS, so
they can be left in production code without any impact on the code size
or speed.
该__UHEAP_MARK和__UHEAP_MARKEND宏确认

默认用户堆是一致的。这项检查的开始使用

 __UHEAP_MARK和随后的电话__UHEAP_MARKEND执行

核查。如果有任何堆细胞分配后调用

 __UHEAP_MARK然后不释放回到堆前的呼吁

 __UHEAP_MARKEND ,恐慌将出现在调试的基础,表明

堆是不一致的。恐慌是ALLOC nnnnnnnn提出,在那里

 nnnnnnnn指针是一个十六进制的第一孤儿堆细胞。

堆检查宏可以嵌套在互相利用

任何地方的代码。他们忽略了释放Symbian操作系统为基础的,因此

他们可以留在生产代码没有任何影响的代码大小

或速度。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值