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
It's not the same TList.Clear
only frees the memory allocated to store the pointers, not objects they are pointing to.
To avoid memory leaks you need to free the memory yourself - as you have been doing - or use TObjectList
.
To answer the second question, TObjectList
doesn't support storing records. You need to use TList
(or something else) in that case.