The TStringList class implements the abstract properties and methods introduced by TStrings.
The TStrings object does not own the objects you add this way. Objects added to the TStrings object still exist even if the TStrings instance is destroyed. Objects must be explicitly destroyed by the application / developer - you. If not, your application will leak memory.
Here are a few examples of storing objects along with strings in a TStringList.
Generic "FreeObjects" for TStrings DescendantsHere's a generic solution to freeing the memory used by objects stored along strings in a TStrings descendant.
procedure FreeObjects(const strings: TStrings) ;
idx : integer;
for idx := 0 to Pred(strings.Count) do
strings.Objects[idx] := nil;
Note: if objects were not added to items, nothing bad with happen if you call the FreeObjects procedure.
Note: Delphi 2009 (and later versions) implementation of the TStringList class exposes the OwnsObjects property. When OwnsObjects is true, objects associated with strings will be freed by the TStringList when items/strings are removed (deleted) from the list.