On Sun, 25 Oct 2015, Zeljko wrote:
On 10/24/2015 03:10 PM, Aradeonas wrote:My question stand but I guess problem is in TObjectList but Im not sure so I made a simple demo like this: procedure TForm1.Button1Click(Sender: TObject); var i: integer; b: TButton; begin list := TObjectList.Create(True); for i := 0 to 10000 do begin b := TButton.Create(Self); list.Add(b); end; end; procedure TForm1.Button2Click(Sender: TObject); begin list.Clear; list.Free; end; Form is clean and just have 2 button with their code so I run it and memory usage in my Windows10 device is about 3mb and then hit the button1 and memory goes up to 25mb and when I want to free and hit button2 memory will decrease to 15mb not 3 , just like my main program that I use TObjectList and will free its objects with remove function but it will increase memory usage while running. Did I miss something obvious?
There is a difference between releasing an object in heap memory, and returning that memory to the OS: It's not because you've released the memories from the various objects in the list, that the memory used by these objects is returned to the OS.
So what you observe is not necessarily an indication of a memory leak. TObjectList does remove the objects from memory in a Clear. If that would not work properly, we'd have heard a long time ago :) Michael. -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
