Delphi应用程序的内存泄露

内存泄漏测试及修复的技巧:(翻译自MemProof帮助的部分内容,翻译得不好,请大家来信指导)

The following are a couple of tips that can be usefull when fixing leaks  in an application :

下面的这些技巧对于修复应用程序的内存泄漏非常有用:

* First just launch the app and then close it. If even this action generates leaks, fix those leaks first. Only after the main leaks are fixed, you should go into specific functionality areas of the application.

*首先,运行应用程序然后马上退出。如果这样操作也产生内存泄漏,先修复这些漏洞。只有先修复这些主要的泄漏,你才能进行特定功能的测试。

* In your Delphi/C++Builder project options, remove as much forms as possible from the Auto-Create option. Create your forms dynamically.

*在你的delphi/C++Builder工程选项中,尽可能地不要使用自动创建窗体,你需要时再动态创建。这点非常重要,自动创建窗体,基本上都会造成未知的内存泄露。


* 注意在循环中创建或分配的内存的代码。如果它们未释放,可能引起大量的内存泄漏。

* Go for the biggest classes first - if you see a TMyFom <class> leaking, try to fix this one first instead of going after a tiny TFont class. Since a Form will usually contain a lot of other classes, with one shot you will have fixed a lot of contained leaks.

*先修复大的类,比如你看到TMyFom 类有泄漏,先解决它的问题,然后再解决像TFont 这样的小类。一个form类经常包含多个子类。修复一个form的未释放问题,你将解决大量该form包含的子对象未释的问题。

* Go for the easy fixes first. Some leaks fixes are very easy and obvious - if you fix the easy ones first, you will keep them out of your way.

*首先修复容易修复的漏洞。一些泄漏是非常容易被发现的,如果你先修复他们,你就不用老想着他们了。

 

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值