Use TObjectList<T>
instead of TList<T>
.
By default TObjectList<T>
will free the object when you delete it from the list or all objects when you free the objectlist itself. This is controlled by the OwnsObjects
parameter of the constructor which is by default True
.