HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Player Group Leaks

05-12-2006, 12:10 PM#1
StRoNgFoE_2000
In my map, I am using a trigger so idle units don't get stuck. After reading many memory leak tutorials and much browsing, I got a good handle on removing almost all of them. Player groups are all I'm really confused on.

I am pretty sure this trigger leaks due to the player groups used. I also read you can destroy player groups, but haven't been able to find a good explanation on destroying player groups or how relevant it is.

Trigger:
AntiStuckUnits
Collapse Events
Time - Every 10.00 seconds of game time
Conditions
Collapse Actions
Player Group - Add Player 7 (Green) to EnemiesBottom
Player Group - Add Player 8 (Pink) to EnemiesTop
Player Group - Add Player 9 (Gray) to EnemiesBottom
Player Group - Add Player 10 (Light Blue) to EnemiesTop
Player Group - Add Player 11 (Dark Green) to EnemiesBottom
Player Group - Add Player 12 (Brown) to EnemiesTop
Collapse Player Group - Pick every player in EnemiesTop and do (Actions)
Collapse Loop - Actions
Set TempGroup = (Units owned by (Picked player))
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Current order of (Picked unit)) Equal to (Order(idle))
Collapse Then - Actions
Unit - Order (Picked unit) to Move To (Center of Top Center <gen>)
Else - Actions
Custom script: call DestroyGroup (udg_TempGroup)
Collapse Player Group - Pick every player in EnemiesBottom and do (Actions)
Collapse Loop - Actions
Set TempGroup = (Units owned by (Picked player))
Collapse Unit Group - Pick every unit in TempGroup and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Current order of (Picked unit)) Equal to (Order(idle))
Collapse Then - Actions
Unit - Order (Picked unit) to Move To (Center of Bottom Center <gen>)
Else - Actions
Custom script: call DestroyGroup (udg_TempGroup)
Player Group - Remove Player 7 (Green) from EnemiesBottom
Player Group - Remove Player 8 (Pink) from EnemiesTop
Player Group - Remove Player 9 (Gray) from EnemiesBottom
Player Group - Remove Player 10 (Light Blue) from EnemiesTop
Player Group - Remove Player 11 (Dark Green) from EnemiesBottom
Player Group - Remove Player 12 (Brown) from EnemiesTop

So if this trigger leaks, is there any way to fix it? And if I destroy the two groups "EnemiesBottom" and "EnemiesTop", will I be able to use them again?

Edit: Sorry, meant to post this into the triggers and scripts forums.
05-12-2006, 12:39 PM#2
Blade.dk
When you create a group variable, wc3 makes sure that it is set to a new, empty group at map init.

I don't see anything that should leak here, as you just add and remove units from already existing groups.

If you destroy the player groups, you can use them again IF you use them with a function that creates a new group that it returns, but you can't add/remove units to them without ensuring that there is a working player group.
05-12-2006, 12:45 PM#3
Vexorian
You have 2 location leaks: (Center of Top Center <gen>) that are never removed

In fact, they are not just 2 leaks, since they are inside of loops they are much more
05-12-2006, 12:55 PM#4
StRoNgFoE_2000
Quote:
Originally Posted by Blade.dk
When you create a group variable, wc3 makes sure that it is set to a new, empty group at map init.

I don't see anything that should leak here, as you just add and remove units from already existing groups.

If you destroy the player groups, you can use them again IF you use them with a function that creates a new group that it returns, but you can't add/remove units to them without ensuring that there is a working player group.

Thanks, that clears things up a bit.

Quote:
Originally Posted by Vexorian
You have 2 location leaks: (Center of Top Center <gen>) that are never removed

In fact, they are not just 2 leaks, since they are inside of loops they are much more

That also clears up an unasked question. I was confused if you order a unit to a point as opposed to creating a unit at a point, that it would leak or not. But of course, the point leaks not the unit.
05-13-2006, 04:02 PM#5
Soultaker
Quote:
Originally Posted by Vexorian
You have 2 location leaks: (Center of Top Center <gen>) that are never removed

In fact, they are not just 2 leaks, since they are inside of loops they are much more

Well, isn't he just pointing to the center of the rect? If he is, then there should be no problem because it will just use the same point over and over.

Please correct me if I'm wrong..

- Soultaker
05-13-2006, 04:10 PM#6
Vexorian
yes, you are wrong.

points are just a pair of real x and y variables

So these functions create one of these pairs. And they behave like pointers.

You can even use MoveLocation(loc,newx,newy) to change the values of both variables.

Because of these 2 locations created by the same function with same arguments are 2 different objects, both may represent the same point but they are different portions of memory
05-13-2006, 04:11 PM#7
Blade.dk
No, it is a new point everytime, even though it is at the same position.