Memory Leaks and (All Players)

Derek0

New Member
Reaction score
1
I just finished fixing all of the memory leaks in my map, and I went to test it. I noticed one of my player loops to disable a skill wasn't working, so I went and looked. This is it:
Code:
        Set PlayerGroup = (All players)
        Player Group - Pick every player in PlayerGroup and do (Actions)
            Loop - Actions
                Player - Disable Channel 1  for (Picked player)
                Player - Disable Channel 2  for (Picked player)
                Player - Disable Channel 3  for (Picked player)
                Player - Disable Channel U  for (Picked player)
        Custom script:   call DestroyForce(udg_PlayerGroup)
I don't see anything wrong with that, do you? After further inspection, it seems that all of my player loops that Set PlayerGroup = (All Players) never happen except the first one. Also, when I set the Pick every player to (All Players) instead of PlayerGroup, the second and up ones still don't happen. Also may I note that things like (All allies of Player 12 (Brown)) work fine.

Is it because (All Players) is passed by reference and DestroyForce(udg_PlayerGroup) destroys (All Players) itself? Or is it that all player groups are passed by reference and I only reused (All Players)? Or is it something else? :confused:

Thanks in advance
Derek0
 

Derek0

New Member
Reaction score
1
I'm not sure about units in (playable map area) because it's part of the units in reigon group which can be any area, but (All Players) may be a constant and may be passed by reference, which means that every time it's used it goes to the same contant, instead of creating a new group which leaks, which means it won't leak, so it's quite possible.
 

SFilip

Gone but not forgotten
Reaction score
634
> Is it because (All Players) is passed by reference and DestroyForce(udg_PlayerGroup) destroys (All Players) itself?
Exactly...
> Or is it that all player groups are passed by reference
They are...

When you use "Units in (Playable map area)" (and pretty much anything on that list except for All player which I'll explain soon enough) somewhere in your trigger the engine picks all units in the playable map area and puts them inside the memory, in a unit group variable.
Set somevariable = Units in (Playable map area)
This makes somevariable point to the group the engine just created. Destroying it does not destroy the variable, but rather the group it points to.

Another example, more important for this issue:
Set somevariable = Units in (Playable map area)
Set someothervariable = somevariable
This makes both somevariable and someothervariable point to the same group, created with the first Set. Destroying either of these will destroy the contents of both.

(All players) is a constant. Setting some variable to (All players) simply makes it point to an already created group. It does not create a new one and thus does not need to be destroyed.

Edit: well a bit slow, two posts came up before this one :p
 

Derek0

New Member
Reaction score
1
(All players) is a constant. Setting some variable to (All players) simply makes it point to an already created group. It does not create a new one and thus does not need to be destroyed.

Exactly what I meant, thanks :)

Now all I need to do is find out how th change the title of a dialog box thats already up.
 

SFilip

Gone but not forgotten
Reaction score
634
Either create a new one or change it before showing.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top