> Can anyone show me how to efficiently free all the memory used by the list 
> and its' objects?
> 

Usually the best way is to use a TObjectList. This frees all attached objects
when they are deleted from the list or the list is cleared or freed.

Otherwise:

var
   TempObject : TMyObject;
begin
      //Go through the list of TMyObject objects
      while AList.Count > 0 do
      begin
        TMyObject(AList.Items[0]).Free;
        AList.Delete(0);
      end;

      //Finally free the TList object
      AList.Clear;

      if assigned(AList) then
         FreeAndNil(AList);

      inherited Destroy; 


_______________________________________________



_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to