tinterfacedobject

why aren't descendants of TInterfacedObject garbage collected?

点点圈 提交于 2019-12-09 00:06:29
问题 i have a class based on TInterfacedObject. i add it to TTreeNode's Data property. TFacilityTreeItem=class(TInterfacedObject) private m_guidItem:TGUID; m_SomeOtherNode:TTreeNode; public end; i create many instances of this object & had assumed that because they're reference counted, i shouldn't need to Free them. that'd be handy. however, when checking this, i turned on ReportMemoryLeaksOnShutdown and found they're not being freed after all. these objects are being created in a frame that's

Reference-counting for objects

╄→гoц情女王★ 提交于 2019-12-04 20:10:21
问题 In my code I use a small data-storing class, which is created in different places. To avoid memory leaks and simplify things, I want to use reference counting, so I did type TFileInfo = class (TInterfacedObject, IInterface) and removed all my manual calls to TFileInfo.Free. Unfortunately Delphi reported a lot of memory leaks. Searching on SO I found the following question explaining why this doesn't work: Why aren't descendants of TInterfacedObject garbage collected? There is a workaround

Reference-counting for objects

眉间皱痕 提交于 2019-12-03 13:50:17
In my code I use a small data-storing class, which is created in different places. To avoid memory leaks and simplify things, I want to use reference counting, so I did type TFileInfo = class (TInterfacedObject, IInterface) and removed all my manual calls to TFileInfo.Free. Unfortunately Delphi reported a lot of memory leaks. Searching on SO I found the following question explaining why this doesn't work: Why aren't descendants of TInterfacedObject garbage collected? There is a workaround presented there but it requires me (at least if i get it right) to write a custom interface IFileInfo and