I just considered using the new TDictionary type. But on QualityCentral, I read about two memory leaks caused by TDictionary:
http://qc.codegear.com/wc/qcmain.aspx?d=67355
I just implemented the proposed workaround, basically subclassing TDictionary, overriding the destructor, and manually freeing up the two objects that cause the leak:
destructor TMemCorrectedDictionary.Destroy;
begin
Values.Free;
Keys.Free;
inherited;
end;
The problem is that the values and keys are read-only properties of the TDictionary, I cannot set them to nil. Well, just to be clear, everything works fine now, but I wondered what would happen if CodeGear releases a patch for a leak and frees two objects again in its own destructor. Wouldn't that lead to an access violation?
Thanks in advance for reading (and hopefully an answer).
source
share