1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Lua] Question about garbage collecting

Discussion in 'Triggers & Scripts' started by BladeMasterRUSH, May 15, 2020.

Tags:
  1. BladeMasterRUSH

    BladeMasterRUSH

    Joined:
    Dec 24, 2019
    Messages:
    6
    Resources:
    0
    Resources:
    0
    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 [​IMG] 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!
     
  2. GetLocalPlayer

    GetLocalPlayer

    Joined:
    Apr 11, 2018
    Messages:
    20
    Resources:
    0
    Resources:
    0
    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.
     
  3. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    876
    Resources:
    0
    Resources:
    0
    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.
     
  4. BladeMasterRUSH

    BladeMasterRUSH

    Joined:
    Dec 24, 2019
    Messages:
    6
    Resources:
    0
    Resources:
    0
    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.
     
  5. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    876
    Resources:
    0
    Resources:
    0
    Yes there are stability issues and excessive desyncs at the moment, I hope this will be temporary :)