title: Delphi - How to free an object that belongs to 2 (or more) Lists
body: <p>In the project I am working on, there are cases where more than one TList objects contain the same item object.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>However, when using FastMM4, the memory leak log lists the items as leaking memory.</p>
  
  <p>So how to go about freeing objects that belong to 2 or more lists?</p>
  
  <p>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)</p>
  
  <p>Thanks,</p>
  
  <p>Bourgui</p>
  
  <p>EDIT</p>
  
  <p>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.</p>
  
  <p>Thanks for all the replies so far.</p>