HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

GroupEnumUnitsInRange native leak

12-29-2006, 10:49 AM#1
grim001
This map contains one trigger. It repeats 1000x per second and does the following:

local group g = CreateGroup()
call GroupEnumUnitsInRange(g, 0, 0, 0, null)
call DestroyGroup(g)
set g = null

This map contains NOTHING else. And it leaks approximately 300k per second. At least, if I run this map and watch my memory usage it climbs 300k per second continuously no matter how long I run it. If I comment out the groupenum it does not leak.

Anyone want to test this and figure out what's going on here? Does the GroupEnumUnitsInRange native leak? Any way to fix it? I noticed this because my map uses GroupEnum like candy and it also has some unexplainable leaks. It looks like this is the cause, but if there's no way to fix it, my map is in trouble...
12-29-2006, 10:55 AM#2
Toadcop
grim001 - yes it's possible ! and i trust you ! and it can't be corrected =( it's blizzard's cool coding ! so we must live with it... the same is with simple units.
12-29-2006, 11:03 AM#3
grim001
Yes, I just tried the same thing with units.

local unit u = CreateUnit(Player(0), 'hpea', 0, 0, 0)
call RemoveUnit(u)
set u = null

This leaks something like 80kb per second for me when repeated 1000x per second. I don't think this is going to ruin anyone's map. The groupenum one is pretty bad though.
12-29-2006, 11:03 AM#4
Hemlock
Don't you think that if you run something a thousand times a second that it will eat your computers memory a bit too, I mea n removing memory leaks is good,but there are limitations to what a computer and wc3 can bear to execute.
12-29-2006, 11:10 AM#5
grim001
Well, I don't think anyone will really use GroupEnumUnitsInRange 1000x per second. But my map does use it tens of thousands of times during the course of a game. The memory usage adds up for maps that use it often.
12-29-2006, 11:15 AM#6
Toadcop
Quote:
Don't you think that if you run something a thousand times a second that it will eat your computers memory a bit too, I mea n removing memory leaks is good,but there are limitations to what a computer and wc3 can bear to execute.
maybe but ! if you do this with triggers for example it will be NO leaks like this! test it!
12-29-2006, 11:50 AM#7
grim001
OK scratch my previous statement that my map uses GroupEnumUnitsInRange tens of thousands of times. It's really more like hundreds of thousands of times.

I have one particular skill that players tend to leave looping for a large portion of their game play time that uses GroupEnum constantly. So let's do some basic math on this ONE skill.

4 GroupEnum per iteration of the loop.
30 times per second.
60 seconds per minute.
30 minutes per game, if they have it on half the time.
3 players using this hero.
4*30*60*30*3 = 648,000 usages from this particular skill alone.

I said earlier that it leaks about 300k from 1000 usages. So this would leak
300 * 648 = 194,400k or 194MB of wasted memory! As you can see this is a game crippling leak for my map. If there is no fix then I will have to make some of my skills less interesting
12-29-2006, 11:54 AM#8
Vexorian
It doesn't leak, but it requires memory, a long ago some guys were claiming it leaks so I tested it in a similar test, it did increase memory usage greatly but eventually stopped doing so. The memory even goes down after some time which does not happen with real memory leaks.
12-29-2006, 12:05 PM#9
grim001
I wonder, just how much memory does it add up to? Whether it's a leak or not, if it can increase memory usage by 100MB before it tops out it's still enough to lag out players with old computers.
12-29-2006, 12:15 PM#10
Toadcop
Quote:
The memory even goes down after some time which does not happen with real memory leaks.
- maybe i can explain this ! if you have 256 RAM (for exaple) war3 will reach maybe to 120 MB size after this it will use Bootfile or how it cals ? and put some unneaded memory to HDD. for example i had 512 RAM and after 300 MB usage of war3 the memory have been decreased after scroll and back. this all must be tested on good system for example ican test it ... today i have 1GB of ram so i will see it correct. ok i will publish my result later. i will run war 20 minutes and create 1000 groups and destroy them single and after will add call GroupEnumUnitsInRange(g, 0, 0, 0, null) to it. and will make the same. i bet it will grove larger and larger !
12-29-2006, 12:54 PM#11
grim001
If anyone is wondering Vexorian says that it caps out at 200+MB but the memory used from groups is dumped periodically, so the maximum amount of memory it eats is directly proportional to how often you spam GroupEnum functions. In practical use I think it might as well be a leak if you use it extremely often. However I'm going to try replacing it with Unit Enters Range events using local triggers. That is what I'd recommend to anyone in the same boat as me.
12-29-2006, 01:55 PM#12
Captain Griffen
It's not a leak. It's simply WC3 grabbing the memory so that it can run more quickly. It isn't designed to do 1000 enums per second.
12-29-2006, 04:18 PM#13
grim001
Regardless of whether it's technically classified as a leak, people should know that it's going to hold huge amounts of memory hostage if they use for something like detecting units in the collision radius of moving units. Thankfully there's the Unit Enters Range trigger alternative.
12-29-2006, 05:59 PM#14
Vexorian
It is not a leak. Normal leaks don't ever stop increasing the memory, this one does stop.

And it is not a big deal unless you do it each 0.02 seconds during a long time, which simply doesn't look like a good idea either way. Worse than the leak is actually the enumeration, the enumeration itself would cause more lag than the 'memory leak'
12-29-2006, 06:27 PM#15
grim001
Even old computers can handle doing multiple GroupEnums per second over a long period of time, but sometimes those computers cannot handle WC3's memory usage going up by 200MB, there would be no problem with doing tons of GroupEnum without this memory "hostage taking" if you don't want to call it a leak