FastMM4、Delphi6、TApplication 泄漏?
我用D6检查了FastMM4。 当我使用“Forms”调试一个简单的应用程序时,每次都会出现 3 行内存泄漏。
此应用程序存在内存泄漏。 小块泄漏是(不包括 由指针注册的预期泄漏):
13 - 20 字节:TObjectList x 3, 未知 x 3 29 - 36 字节: TWinHelpViewer x 1 37 - 52 字节: 帮助管理器 x 1
这正常吗?
这是什么原因造成的?
谢谢: DD
I checked the FastMM4 with D6.
When I debug a simple application with uses "Forms", I everytime got 3 lines for memory leak.
This application has leaked memory.
The small block leaks are (excluding
expected leaks registered by pointer):13 - 20 bytes: TObjectList x 3,
Unknown x 3 29 - 36 bytes:
TWinHelpViewer x 1 37 - 52 bytes:
THelpManager x 1
Is this normal?
Which thing causes this?
Thanks:
dd
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Delphi 6 附带的 RTL/VCL 包含一些内存泄漏。在 Delphi 的后续版本中,FastMM 的使用导致这些内存泄漏被从 RTL/VCL 中删除。
您需要做的就是使用 FastMM 注册这些已知的和预期的内存泄漏。一旦您注册了泄漏,FastMM 就不会报告它们。尽管这些泄漏是真实存在的,但由于各种原因,最好忽略它们:
这些泄漏唯一可能产生影响的情况是,如果您的 DLL 在该进程的生命周期内从同一进程加载和卸载了数千次。我不认为这是一个非常现实的场景。
如果您不注册泄漏,那么 FastMM 泄漏报告将变得基本上无效,因为它每次都会显示。如果每次你学会忽略它时都会出现。此泄漏报告非常有价值,但只有当它显示您可以控制的泄漏时才有价值。
在我的 Delphi 6 项目中,我的 .dpr 文件中有以下代码:
我的应用程序中的所有表单均从其后代中继承,在
TForm
后代中也有以下代码:具体取决于您在RTL/VCL以及你如何使用它们,你可能需要注册不同的内存泄漏。
The RTL/VCL that ships with Delphi 6 contains some memory leaks. In later releases of Delphi the use of FastMM led to these memory leaks being removed from the RTL/VCL.
What you need to do is register these known and expected memory leaks with FastMM. Once you have registered the leaks that FastMM won't report them. Although these leaks are real, they are best ignored for various reasons:
The only time these leaks could matter is if you had a DLL which was loaded and unloaded from the same process thousands of times during the lifetime of that process. I don't believe this is a very realistic scenario.
If you don't register the leaks then the FastMM leak reporting becomes largely ineffective because it shows every time. If it shows every time you learn to ignore it. This leak reporting is very valuable, but it is only valuable if it shows leaks that you have some control over.
In my Delphi 6 project I have the following code in my .dpr file:
I also have the following in a
TForm
descendant from which all forms in my app descend:Depending on exactly which units you use in the RTL/VCL and how you use them, you may need to register different memory leaks.
我猜这是正常的,除非你修补了源代码。 IIRC,当出现“memproof”时,其作者“Atanas Stoyanov”保留了导致内存泄漏的错误列表。 “classes.pas”fi 中的泄漏影响了每个 VCL 表单应用程序。尽管该产品已不存在,但您可以在“自动化 QA”网站上找到该列表。这是D6 列表。
I would guess it is normal unless you patched the sources. IIRC, when there was 'memproof', its author 'Atanas Stoyanov' kept a list of bugs that caused memory leaks. The leak in the 'classes.pas', f.i., effected every VCL forms application. Though the product does not exist anymore, you can find the list at 'Automated QA's site. Here's the list for D6.