[Lua] Question about garbage collecting

Status
Not open for further replies.
Level 6
Joined
Dec 24, 2019
Messages
19
Hello! I am currently in the process of converting a map from JASS to LUA. Right now the map has no JASS script calls besides the standard manual
86e9ce77a8ae136530cd9deda5733a80.png
garbage collection in GUI triggers. The gist is that this map is done entirely in GUI (and there are quite a few triggers) and only uses the above JASS 'script'. I'd like to convert the map to Lua, and in order to do so I've read (and tested) that I need to either

[1]. Export all triggers, delete triggers, swap import triggers
[2]. Disable all triggers using the above custom script call

Now, since the GUI triggers are so interconnected, doing either of those will require hours of reconnecting units and triggers (since disabling a trigger disables dependencies etc. etc.)...

I was wondering if I would be able to just delete these RemoveLocation() calls without any major loss to performance? I've read/been told that LUA has its own garbage collection, making the above calls... unnecessary to an extent. If that is the case, then I would only need to delete 216 instances of the above call rather than spend an extra 2-3 hours adjusting the call and re-connecting triggers.

Thank you so much!
 
Level 4
Joined
Apr 11, 2018
Messages
24
I've read/been told that LUA has its own garbage collection, making the above calls
No, Lua's garbage collector does not work with "handle" type. Such objects is something that exists on your map during runtime and isn't controlled by Lua. But we can force Lua to do it.
Also Lua allows us to override functions that are used in GUI to remove all the leaks you had to remove manually before automatically.
 
Level 12
Joined
Jan 30, 2020
Messages
875
Well all unused handles need to be destroyed, even in Lua.
In Lua though you do not need to "null" variables referencing these handles.

Best thing you could do unless you want to spend 2 months 18h a day like I did to convert your map in Lua by hand, you could simply replace these custom script calls to follow Lua's syntax thus something like "Custom Script : RemoveLocation(udg_TempPoint)" and then change your script language to Lua in the map options.

Maybe you might even need to remove all custom script actions, save them on a copy of your map, remove them from your map, change the scripting language to lua, and then add these custom script actions back and change their syntax.

Unfortunately, @Dr Super Good 's GUI leak obliterator seems to have desync issues for the moment, so what I advised you to do might be the only solution for the moment.
 
Level 6
Joined
Dec 24, 2019
Messages
19
Well all unused handles need to be destroyed, even in Lua.
In Lua though you do not need to "null" variables referencing these handles.

Best thing you could do unless you want to spend 2 months 18h a day like I did to convert your map in Lua by hand, you could simply replace these custom script calls to follow Lua's syntax thus something like "Custom Script : RemoveLocation(udg_TempPoint)" and then change your script language to Lua in the map options.

Maybe you might even need to remove all custom script actions, save them on a copy of your map, remove them from your map, change the scripting language to lua, and then add these custom script actions back and change their syntax.

Unfortunately, @Dr Super Good 's GUI leak obliterator seems to have desync issues for the moment, so what I advised you to do might be the only solution for the moment.
Thanks Macadamia, I appreciate the insight. I was able to convert my map to Lua but had some issues so just waiting for stability updates from Blizzard now.
 
Status
Not open for further replies.
Top