title: How to free runtime ListBoxItems from memory in Delphi Seattle Firemonkey Multi Device App
body: <p>I have a few forms where I have a TListBox component that I fill runtime. </p>
  
  <p>My question is how can I best free the items that I add runtime?</p>
  
  <ul>
  <li>By using the owner? Form or ListBox?</li>
  <li>Or freeing them myself? </li>
  <li>or a different way?</li>
  </ul>
  
  <p>Below an example how I fill my listbox:</p>
  
  <pre><code>procedure TForm1.LoadList;
  var
    item: TListBoxItem;
  begin
    myList.Clear;
    myList.BeginUpdate;
    try
      with myQuery do
      begin
        First;
        while not eof do
        begin
          item := TListBoxItem.Create(nil);
          try
            item.Tag := FieldByName(myIDField).AsInteger;
            item.Text := FieldByName(myDescriptionField).AsString;
            myList.AddObject(item);
          finally
            Next;
          end;
        end;
      end;
    finally
      myList.EndUpdate;
    end;
  end;
  </code></pre>
  
  <p>I do have noticed that creating the list may take a bit longer when I set the owner of the item.
  Also when the I call ListBox.Clear and the list was filled with items with no owners the list still gets cleared correctly. So does this mean the owner of the items get set when I use AddObject to add them to the ListBox?</p>
  
  <p>Also I Free the form with the close action:</p>
  
  <pre><code>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  begin
    Action := TCloseAction.CaFree;
  end;
  </code></pre>
  
  <p>I don't know if this changes things how to free the items in my list?</p>