Hi all,
In the project I am working on, there are cases where more than one TList objects contain the same item object.
Essentially, there is a master list which contains all the item objects, then smaller lists that contain only a subset of all the items. The items are the same however, not a copy.
Where the problem arises is during destruction. The main list is freed, which frees all of the items. The main list takes care of freeing the items, by overriding "notify", and the sub-lists override the "Notify" event so that the item is not freed a second time - which would fail anyway.
However, when using FastMM4, the memory leak log lists the items as leaking memory.
So how to go about freeing objects that belong to 2 or more lists?
By the way, this is not my code, I'm just doing some light maintenance on it. I'd like to avoid having to create a clone of each object to put in the separate lists if I can, but hey, a man's gotta do what a man's gotta do :o)
Thanks,
Bourgui
EDIT
Nevermind, I must be crazy. Now FastMM4 doesn't flag the items as leaking... Only the sub-lists, which are actuallya sub-class of the main list. There must be something I'm missing here. I'm going to run more tests to get a clearer picture of what is going on.
Thanks for all the replies so far.