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 make many examples of this object & amp; It was assumed that because they are counting the references, I will not need to free them. It would be easy.
However, while checking this, I turned on ReportMemoryLeaksOnShutdown and found that they are not being freed after all.
These objects are being built in a frame on the main form. In the main form of formulas, I clean the tree nodes, as if everything should be freed.
What's going on?
Thank you for your help!
TInterfacedObject is not a reference math, only the interface is you can apply the interface using TInterfacedObject , Which basically saves an attempt to implement your reference counting methods. Unfortunately it still will not work in your case: The compiler does not know that you are specifying the interface for TTRINode.data property because it has not been declared as the interface but as an indicator then all Weird things of type are:
MyInt: = TFacilityTreeItem.Create; // Reg calculation = 1 // node. Data: = myInt; // will not compile the node. Data: = pointer (mant); // There is no interface assignment, the countdown count is 1 ... end; // Reg Count goes to 0, your object is free
as soon as you have your object Try to access data through a property, you will get an access violation.
So, do not bother with the interface in this case, you can work it out, but it will be more than worth it.
Comments
Post a Comment