• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

DestroyUnit

This is on the premise that RemoveUnit causes permanent leaks in memory. Users without JassHelper may simply copy the function into the top map-script.

JASS:
library DestroyUnit
    
    function DestroyUnit takes unit target returns nothing
        call UnitApplyTimedLife(target, 'BTLF', 0)
        call ShowUnit(target, false)
    endfunction
    
endlibrary
 
Last edited:
wth??? and how does this remove the memory leaks?

I'd like you to perform a test comparing this method with RemoveUnit and tell me that this does not result in the exact same memory leaks over a 10 hour period : |.


It was determined that any time a unit handle goes out of scope it leaks. This happens with the Chaos ability too. I don't see why decay is so special.


Furthermore, what if the unit never decays?

*votes for rejection*

: D
 
So a melee game that stretches on forever will eventually crash if so many units are destroyed and remade? That would be pretty faulty of Blizzard to not only mess up JASS but mess up their entire game, as well.

in short, yup. In one of the recent patches (last 2), the memory leak got much worse : |.


I didn't notice it from tests but from playing games. I only play games with LOTS of units and so when I'm suddenly crashing every 1.5 games when I used to rarely crash that's a MAJOR difference in the memory leaks o-o. It's especially noticeable when I'm playing the exact same maps and before a patch I'm getting no crashes and after the patch I'm getting memory read errors >.>.

So yea, the game was screwed up originally with unit handles. After recent patches, it was horribly screwed. I don't know if they did this on purpose to push sc2 or what, but it's /cry.


And even if the decaying units somehow didn't leak (if*), there is the issue that not all units are flagged to decay making this script totally unstable ; D.


All of the JASS veterans know that Blizzard has royally screwed up portions of their game and we all know that Blizzard will probably never fix it. They've fixed some things that were screwed up, but they seem to make the unit handle leak more each patch >.<.
 
Yeah, I have fixed it for timed life. Azlier or whoever is reading this should likely just graveyard this if it just isn't worth it.

I didn't say timed life would prevent the leak... when I said try it, I meant test it and compare it with RemoveUnit over a long period of time to see if it leaks... be sure to use multiple units of different types and be sure to add variance to the number of units on the map at any given point.

I'm 99% positive that timed life will cause the same leak >.>.. I don't think there is any solution to the unit handle leak except maximizing recycling of units with a revive function. Even then, I still don't think it will work. A corpse might be a sup type of unit meaning that reviving a unit would still call destructor/create.
 
No unit-recycling library I've ever seen factor in unit-facing, which is needed for projectile systems and for starcraft-templar type movement where a unit leaves a temporal trail of its own self.

I have thought of doing a dummy-recycling library which factors in unit-facing (for ProjectileUtils) though I don't know the proper way to index each dummy by facing angle.
 
No unit-recycling library I've ever seen factor in unit-facing, which is needed for projectile systems and for starcraft-templar type movement where a unit leaves a temporal trail of its own self.

I have thought of doing a dummy-recycling library which factors in unit-facing (for ProjectileUtils) though I don't know the proper way to index each dummy by facing angle.

wth?? what you can do is catch the decay event an instant before it goes and pause the unit. When you need it, you just revive it. You store the units into a hashtable using the unit type id as first index and count as second index.

The memory overhead on this would be enormous if the map ever spiked in counts.. hell, the memory overhead would be enormous no matter what. This is why I've never done and never plan to do a system like this... >.>

All we can do is restart wc3 after every x custom games and make sure a custom game with lots and lots of units doesn't go on for more than 45 minutes or so... I know my footmen wars map would crash 15 minutes into the game from unit leaks... yea.. would have hundreds of units on the map every second of the game or more, many with a 1-3 second timed life (imagine 100 units turning into 400 turning into 800 and then all going away and then more surges and waves like that through out the game). My maps crash just about every time halfway into the game or sooner because of how many units I use. I can guarantee you I've been trying to find a solution to this problem...

One thing that irritates me is people say limits/problems on wc3 and sc2 are big enough that nobody would ever run into problems if their map was properly coded. Guess what, my maps are properly coded and I've run into these problems for every single one of my maps... I can't even move to sc2 because there isn't enough RAM memory to support the maps I make..
 
I would think something like footman wars easy to recycle dummy. You just limit how many units can be recycled.

If I did a recycle-dummy-by-unit-facing function, I would only store 20-30 dummies max at semi-acute angles. 30 dummies, properly stored, would have facing angles every 12 degrees. In Wc3, that's what you call close enough, because any correction in facing the dummy would have to do would be 6 at maximum, with an average of 3 degrees off.
 
Why are you concerned about unit facing with unit recycling??

Also please don't do unit recycling because a given map may have many different types of units... remember, units on the map, even if they are paused and hidden, will start to lag the game as well >.<.


Only viable way to make it so units stop leaking is to beg blizzard to fix it.
 
Top