Treeview memory leak lazarus / 31-LCL ---------------------------------------------------------------------- wp · 2016-02-15 00:24 In the simple demo project that I posted for another topic (http://for um.lazarus.freepascal.org/index.php/topic,31521.msg202076.html#msg2020 76) heaptrc reports a bunch of memory leaks although I am pretty sure that created objects are properly destroyed. In this demo, instances of a simple class are attached to the Data pointer of the tree nodes. The data are destroyed in the OnDeletion event of the treeview. To check load the attachment from http://forum.lazarus.freepascal.org/ index.php/topic,31521.msg202076.html#msg202076 and enable the heaptrc option in the project options. Run, click "Add", enter some dummy data, "OK", and close the program. --> heaptrc reports more than 300 unfreed memory blocks! It is strange that none of the reported leaking lines is in my code. Has anybody else seen this? ---------------------------------------------------------------------- Blaazen · 2016-02-15 00:54 The leak doesn't come from TreeView or its data but from Form2. Adding line 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 F.Free;to the end of method Unit2.CreateData resolves problem. That's because F is created without owner -> noone frees it. ---------------------------------------------------------------------- taazz · 2016-02-15 01:01 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 function CreateData: TMyData;var  F: TForm2;begin  F := TForm2.Create(nil);  try    if F.ShowModal = mrOK then begin      Result := TMyData.Create;      Result.FName := F.EdName.Text;      Result.FAddress := F.EdAddress.Text;      Result.FCity := F.EdCity.Text;      Result.FBirthday := F.EdBirthday.Date;    end else      Result := nil;  finally    F.Free;  end;end; ---------------------------------------------------------------------- wp · 2016-02-15 09:16 Thank you guys. I should not post code that I wrote too late at night...