Freeing TList<T>

I am unsure:


var
  Customers: TList<TCustomer>;
begin
  Customers := Manager1.Find<TCustomer>.List;



According to the docs, I have to free the List myself.

If I need to retrieve data again, this is the correect approach?


var
  Customers: TList<TCustomer>;
begin
  Customers := Manager1.Find<TCustomer>.List;
….

 Customers.Free;
  Customers := Manager1.Find<TCustomer>.List;


No, Customers.Free; destroy original Manager1.Find<TCustomer>.List;

I do not understand. Can you provide a code sample?

No preview needed. In Customers he put a pointer to Manager1.Find <TCustomer> .List; No value! You may not use Customers.Free; That is all. You only destroy objects when you don't need them.

Whenever you call the "List" method, it will create a TList object that you need to destroy. So your code should be something like this:


I'll be quiet. I did not know that a new object instance was being created. I used my experience with Delphi.