2013-03-18 60 views
2

我使用FastMM4在FullDebugMode查找內存泄漏,而且我得到了很多的抱怨UnicodeStringTListTParameters等情況下是這樣的:RTL和VCL內存泄露

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內部結構和可能的內存泄漏嗎?如果是的話,我能做些什麼呢?

+0

@DavidHeffernan我會嘗試創建一個簡約的應用程序。 – 2013-03-18 11:20:06

回答

6

我應該關心RTL和VCL內部以及它們內部可能的內存泄漏嗎?

大概不會。最近版本的RTL/VCL很乾淨。我沒有遇到與他們的泄漏,雖然這並不是說你不會。

無論如何,您呈現的報告看起來就像您的代碼中的例行內存泄漏。當你的代碼泄漏時,通常發生的是你創建一個對象然後不能銷燬它。泄漏的物體可以擁有許多其他物體。他們都被FastMM跟蹤並報告爲不同的泄漏。所以,如果你創建一個包含字符串的對象,那麼泄漏擁有的對象也會泄漏字符串。

+0

感謝您的明確解釋。 – 2013-03-18 11:26:36

+0

不幸的是,FastMM不能遍歷那些沒有被釋放的對象樹,併爲你簡化它,但是如果你有XE2或者XE3,那麼試試AQTime,它將幫助你識別已經泄露的真實對象。 – 2013-03-18 21:17:19

+0

@WarrenP上次我犯了讓AQTime進入我的機器的錯誤,IDE每5分鐘就會崩潰! – 2013-03-18 21:18:58