I'm a bit puzzled of what to use for storing objects in a list.
Until now I have used TList
and freed each item in a loop. Then I discovered TObjectList
that do this automatically from Free
. Then I saw this from the doc of TList.Clear
:
Call
Clear
to empty the Items array and set theCount
to 0.Clear
also frees the memory used to store theItems
array and sets theCapacity
to 0.
So it is basically the same. So
for TList
mylist.Clear;
myList.Free;
is the same as for TObjectList
?
myList.Free;
Can TObjectList
only be used for items as classes or can I store records?