Using FV's TListBox, Memory Leak, lazarus / 65-FV-Textmode IDE ---------------------------------------------------------------------- gasensor · 2022-05-02 17:16 I am Using FV's TListBox. But find it Memory Leaked. It has been bothering me for a long time. sechshelme 's "FPC FreeVision Tutorial"  do not have a  TListBox DEMO... Can anyone give me an example of how to use TLISTBOX properly? TKS ---------------------------------------------------------------------- Mathias · 2022-05-22 15:30 After trying back and forth for a long time, this unpleasant memory corpse remains with TList. I have described all the findings in my GitHub Issues channel. https://github.com/sechshelme/Lazarus-FreeVision/issues/3 I tried out several components, where I created them and then released them again with Dispose/Done. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i constructor TMyDialog.Init;var  Rect: TRect;  ScrollBar: PScrollBar;  i: Sw_Integer;  rad: PRadioButtons;  bp:PButton;const  Tage: array [0..6] of shortstring = (    'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'); begin  Rect.Assign(10, 5, 67, 17);  inherited Init(Rect, 'ListBox Demo');   rad := New(PRadioButtons, Init(Rect, NewSItem('~G~ross', NewSItem('~M~ittel', NewSItem('~K~lein', nil)))));  Dispose(rad, Done); // io.   bp := New(PButton, Init(Rect, '~T~ag', cmTag, bfNormal));  Dispose(bp, Done); // io.  exit; But if I do the same with PListBox, there are memory corpses. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ListBox := new(PListBox, Init(Rect, 1, nil));  Dispose(ListBox, Done);  // Memory Leak !  exit; Could there be a bug in PListBox? ---------------------------------------------------------------------- Mathias · 2022-05-23 16:36 I took a closer look at the TFileListBox used by the TFileDialog. Then I came across the following: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i destructor TFileList.Done;begin  if List <> nil then Dispose(List, Done);  TListBox.Done;end; They added their own destructor there. Now I also built a new ListBox and added a destructor and used this ListBox in my dialog. As it seems, this works. the memory leak is gone. I'll make a few more tries. In my opinion, this is a bug in TListBox, which lacks the destructor. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  PNewListBox = ^TNewListBox;  TNewListBox = object(TListBox)    destructor Done; virtual;  end;...destructor TNewListBox.Done;begin  if List <> nil then begin    Dispose(List, Done);  end;  TListBox.Done;end;constructor TMyDialog.Init;var  Rect: TRect;  ScrollBar: PScrollBar;  i: Sw_Integer;const  Tage: array [0..6] of shortstring = (    'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'); begin  Rect.Assign(10, 5, 67, 17);  inherited Init(Rect, 'ListBox Demo');   // StringCollection  StringCollection := new(PStringCollection, Init(5, 5));  for i := 0 to Length(Tage) - 1 do begin    StringCollection^.Insert(NewStr(Tage[i]));  end;   // ScrollBar für ListBox  Rect.Assign(31, 2, 32, 7);  ScrollBar := new(PScrollBar, Init(Rect));  Insert(ScrollBar);   // ListBox  Rect.Assign(5, 2, 31, 7);  ListBox := new(PNewListBox, Init(Rect, 1, ScrollBar));  ListBox^.NewList(StringCollection);  Insert(ListBox);   // Cancel- Button  Rect.Assign(19, 9, 32, 10);  Insert(new(PButton, Init(Rect, '~T~ag', cmTag, bfNormal)));   // Ok-Button  Rect.Assign(7, 9, 17, 10);  Insert(new(PButton, Init(Rect, '~O~K', cmOK, bfDefault)));end; ---------------------------------------------------------------------- Mathias · 2022-05-30 15:21 So, now a tutorial for ListBoxes has been added. With the ListBoxes, you can manually remove the loaded list from memory. This is described in the tutorial.