[v2.122] Class.New() memory leak Topic is solved

Discuss the future of the AutoHotkey language
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

[v2.122] Class.New() memory leak

Post by HotKeyIt » 13 Dec 2020, 22:24

After merging v2.122 I checked the build for memory leaks and could not resolve it yet, here is an example to reproduce:

Code: Select all

Loop
	a%A_Index%:=MyClass.new(),a%A_Index%:=""

Class MyClass{
}
Same with built-in Class:

Code: Select all

Loop
	a%A_Index%:=Array.new(),a%A_Index%:=""
Gui.new seems to have memory leak too but memory grows very slow compared to above:

Code: Select all

Loop
	a%A_Index%:=Gui.new(),a%A_Index%:=""
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: [v2.122] Class.New() memory leak  Topic is solved

Post by swagfag » 14 Dec 2020, 03:00

im not convinced it's the .New() thats causing the supposed leaks. this script declares a bunch of global(but this probably doesnt matter) variables. they have to be stored somewhere, which takes up some bit of space. im not sure whether theres any kind of mechanism built into ahk to prune blanked-out(seldomly accessed) cached variables, but there probably isnt

the gui example grows more slowly probably because the gui actually has to set up a gui, which is a more expensive operation in comparison
HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [v2.122] Class.New() memory leak

Post by HotKeyIt » 14 Dec 2020, 03:56

Thanks, you are right, testing further shown that global variables consume that memory, didn't think that it would be that much.
In that case I need to look deeper in code to find the memory leaks, since on exit the objects cannot be cleared because they have left references (tested using vld.h).
Post Reply

Return to “AutoHotkey Development”