title: How to free a generic TList<TMyRecord> with generic sub lists in TMyRecord
body: <p>In Delphi 10 Berlin under Windows I have the following question regarding the freeing of generic lists:</p>
  
  <p>I have the following record/list structure:</p>
  
  <pre><code>type
    TMyRecord=record
      Value1: Real;
      SubList1: TList&lt;Integer&gt;;
      SubList2: TList&lt;Real&gt;;
    end;
  
    TMyListOfRecords=TList&lt;TMyRecord&gt;;
  </code></pre>
  
  <p>I want to free the structure with the following code:</p>
  
  <pre><code>var
    i: Integer;
    AMyListOfRecords: TMyListOfRecords;
  begin
    //other code
  
    //free AMyListOfRecords and all its content
    for i:=0 to AMyListOfRecords.Count-1 do
    begin
      AMyListOfRecords[i].SubList1.Free;
      AMyListOfRecords[i].SubList2.Free;
    end;
    AMyListOfRecords.Free;
  end;
  </code></pre>
  
  <p>This seems to work. But I am wondering if there is a simpler or more elegant solution?      </p>