2

我在FullDebugMode中使用 FastMM4来查找内存泄漏,我收到了很多关于UnicodeString, TList,TParameters等实例的投诉,如下所示:

A memory block has been leaked. The size is: 276
This block was allocated by thread 0x2928, and the stack trace (return addresses) at the time was:
404CFE [System][@GetMem$qqri]
408C0F [System][@NewUnicodeString$qqri]
408E40 [System][@UStrFromPWCharLen$qqrr20System.UnicodeStringpbi]
408F17 [System][InternalUStrFromPCharLen$qqrr20System.UnicodeStringpcii]
5C006B [Vcl.Themes][Themes.TUxThemeStyle.GetElementDetails$qqr27Vcl.Themes.TThemedScrollBar]
774861EF [GetWindowLongW]
74B6588B [Unknown function at DrawThemeParentBackground]
74B6586C [Unknown function at DrawThemeParentBackground]
74B6780B [Unknown function at OpenThemeData]
7748C5FE [Unknown function at gapfnScSendMessage]
77481B31 [Unknown function at PeekMessageA]

The block is currently used for an object of class: UnicodeString

A memory block has been leaked. The size is: 20    
This block was allocated by thread 0x2928, and the stack trace (return addresses) at the time was:
404CFE [System][@GetMem$qqri]
406EB3 [System][TObject.NewInstance$qqrv]
407556 [System][@ClassCreate$qqrpvzc]
406EE8 [System][TObject.$bctr$qqrv]
814DD8 [Datasnap.DBClient][Dbclient.TCustomClientDataSet.ClearActiveAggs$qqrv]
815359 [Datasnap.DBClient][Dbclient.TCustomClientDataSet.ResetAllAggs$qqro]
80D8AC [Datasnap.DBClient][Dbclient.TCustomClientDataSet.InternalOpen$qqrv]
6948D7 [Data.DB][Db.TDataSet.DoInternalOpen$qqrv]
69498F [Data.DB][Db.TDataSet.OpenCursor$qqro]
80CA87 [Datasnap.DBClient][Dbclient.TCustomClientDataSet.OpenCursor$qqro]
69484B [Data.DB][Db.TDataSet.SetActive$qqro]

The block is currently used for an object of class: TBits

我目前的内存泄漏报告大约有两兆,而且它的大部分内容都是这样的。怎么了?我应该担心它们RTLVCL内部结构和可能的内存泄漏吗?如果是,我能对他们做些什么?

4

1 回答 1

6

我是否应该担心 RTL 和 VCL 内部以及其中可能存在的内存泄漏?

可能不是。RTL/VCL 的最新版本是干净的。我没有遇到过他们的泄漏,尽管这并不是说你不会。

无论如何,您提供的报告看起来就像代码中的例行内存泄漏。当您的代码泄漏时,通常发生的情况是您创建了一个对象,然后未能销毁它。泄漏的对象可以拥有许多其他对象。它们都被 FastMM 跟踪并报告为明显的泄漏。因此,如果您创建一个包含字符串的对象,那么泄漏拥有的对象也会泄漏字符串。

于 2013-03-18T11:23:39.220 回答