• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Player Group Leak Confirmation

Status
Not open for further replies.
Level 3
Joined
Feb 25, 2019
Messages
35
I know I've posted like a thousand times, sorry, but like I said... I am brand new. I have found myself remaking a majority of my triggers upon realizing something new about leaks probably 3-4 times now...
  • Locations leaking
  • Using a location as a reference point for a polar offset location leaks both locations (ow..)
  • Wait In-game-time leaking (mega ow... I used this way too much)
  • Many, many more...
I just realized there may be another frequently used method by me that could be a leak as well, I want to confirm if I have to do something about this or not:

"Display to (PlayerGroup(ConvertPlayerToPlayerGroup(Player)))..."

Does that create a player group that then leaks, similar to creating a unit group then needing to destroy that unit group?
 
Level 11
Joined
Jul 4, 2016
Messages
627
Yes, it does leak a player group.

You can use this function if you still want to use waits but avoids the leak. Copy it to your map header, which is the map icon.

JASS:
function WaitGameTime takes real duration returns nothing
        local timer t
        local real  timeRemaining
     
        if duration > 0 then
            set t = CreateTimer()
            call TimerStart(t, duration, false, null)
            loop
                set timeRemaining = TimerGetRemaining(t)
                exitwhen timeRemaining <= 0
             
                if timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD then
                    call TriggerSleepAction(0.1 * timeRemaining)
                else
                    call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
                endif
            endloop
            call DestroyTimer(t)
            set t = null
        endif
    endfunction

Then just do
JASS:
 Custom Script: WaitGameTime(2.5)
 
Last edited:
Level 3
Joined
Feb 25, 2019
Messages
35
^Yes. You can read here how to remove also a Player Group. Things That Leak : )

Once you want also some read behind it you can have a look here Memory Leaks.
Thank you so much for the answers guys... I have one more clarification to make: If I use "(unit) is an enemy of (OwnerOfUnit(unit2)) = true," do I have to worry about potential player group leaking there? It doesn't seem to me to involve a player group, but the terminology seems similar.. and this is GUI.. so for all I know it could just be doing the "ConvertPlayertoPlayerGroup" in the background. Does it leak?
 
Level 3
Joined
Feb 25, 2019
Messages
35
No it doesn't create any player group behind. : )
Oh thank goodness.. I honestly don't think I could've handled that with how much I use that... Sorry for asking so many questions, you've been really helpful, I got a lot of issues in my map fixed today bc of this help!
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
Sorry for asking so many questions
Ask as many as you have, this forum is for information/help and we (probably?) expect to get bombarded as Reforged gets underway so you're not gonna be an odd man out.

I saw someone here (sorry I can't @ them because don't remember who) used this nifty setup to avoid dealing with playergroups and having to destroy them. Just use one global PG variable that you add people to before using.
  • Player Group - Add (Triggering Player) to PG
  • -------- Do whatever here that uses PG --------
  • Game - Display to PG the text "whoo!"
  • Player Group - Remove (Triggering Player) from PG
  • -------- this line may exist too in GUI, not sure, but if it is you can use it instead --------
  • Player Group - Remove all players from PG
 
Status
Not open for further replies.
Top