HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Memory Leak Question

06-13-2004, 06:46 PM#1
Lil Blue Smurf
If I do a

Pick random unit of type (whatever) within x distance of (triggering unit) and do unit-remove unit

is there any mem leak going on? I would think not, but who knows, maybe they have it set up to make the units a group that gets stored or something else unexpected, it will be used fairly often so I just want to be sure.
06-13-2004, 06:55 PM#2
th15
To my knowlede, using ANY of the "Unit group- Pick every..." actions causes a new unit group variable to be created. This unit group variable is not destroyed after it is used. If there is any reference to a position (something like Position of Triggering unit), that will also leak.

Thing is, I'm not sure how to prevent a mem leak here without breaking the function. You see, adding each picked unit to a unit group, removing the units in the uit group then destroying the unit group might only pick 12 units (unit groups can only handle 12 units). Hopefully someone can offer some info about that. Frankly I'm quite interested in this because my latest map uses a hundred unit groups.
06-13-2004, 07:43 PM#3
Lil Blue Smurf
Okay, actually, here is the exact trigger I am using... it doesn't do a unit group-pick units, but it does do a reference to units of group within range

Code:
set temppoint=position of (ordered unit)
unit - remove (random unit from (units within 200 of temppoint matching (unit-type of matching unit) equal to rifleman
remove udg_temppoint
06-14-2004, 04:16 PM#4
Anitarf
...(units within 200 of temppoint matching (unit-type of matching unit)...

well, basicaly, this is a unit group, so this leaks. Store this unit group into a variable first, then remove a random unit from it, and then destroy the unit group.
06-14-2004, 04:33 PM#5
Cubasis
What anitar said is 100% correct. And for more info you can read my (now featured) article on the subject.

th15, UnitGroups can handle "almost" (in a sense that we have yet to run into a limit) endless units. There is no obvious limit there. It is only UnitGroup "orders" that affect only 12 units, just like you can only order 12 units at a time to do anything in WC3.

And there is no problem with Destroying a group that has had it's contents messed with. As UnitGroups are just lists of units, and you can destroy the list no matter what it includes. Destroying the list does not destroy the content in any way (f.ex. killing the units).

~Cubasis
06-14-2004, 06:19 PM#6
Lil Blue Smurf
Okay thanks, think that answers it :)
06-14-2004, 07:10 PM#7
Anitarf
I have a question regarding unit groups and memory leaks myself. To my understanding, a variable is something that points to a unit group so that we can destroy that unit group before assigning a new value for the variable to point at. What about actions such as add unit to unit group or remove unit from unit group? Do they make the variable point to an new unit group (which has one more/less unit in it than the original group), leaving the previous group to leak, or is the unit added directly to the list of units to which the variable points? if the later is the case, then does anything remain to leak if not destroyed after you remove all units from a unit group?