TLists -- Freeing Objects

I have memory leaks in my TList code.  Will a TList free the objects I add to it or do I have to free each individual object??  Sample code would be nice.
stimpy031597Asked:
Who is Participating?
 
mheacockConnect With a Mentor Commented:
You have to free each individual object.  See sample code in comment below.
0
 
mheacockCommented:
for I := 0 to List1.Count - 1
    Free(List1.Items[I]);
List1.Free;

You'll have to free each object according to how you instantiated it...either using the Free function or a Free method or whatever.
0
 
stimpy031597Author Commented:
Thanks, I can figure the rest out myself.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.