• 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.

Is using "RemoveUnit()" okay?

Status
Not open for further replies.

Deleted member 219079

D

Deleted member 219079

Found two resources that solve your concern:
[System] MissileRecycler
[Snippet] Dummy Reuser

FYI, there's no such thing as instant turning. But already separating circle (360 degrees) into 8 sectors and storing dummies to 8 respective arrays makes the user unable to spot any difference. If you don't need such feature, the latter resource will suffice.

Edit: Well seems like someone created a bible in the place of API to explain it.
 

Deleted member 219079

D

Deleted member 219079

Your dummy classifies as an unit. I found this from the depths of Hive somewhere (ofc I don't expect you to dig every corner before posting, so I dug it up for you):

When a unit dies it starts decaying, if it can. After it's decayed it will be removed from game. RemoveUnit() directly removes the unit from game.

From tests in pasts units seem to always leak a tiny bit of memory, even after being removed from game (~0.04kb). A question about trigger leaks
 
Level 13
Joined
Jan 2, 2016
Messages
978
Your dummy classifies as an unit. I found this from the depths of Hive somewhere (ofc I don't expect you to dig every corner before posting, so I dug it up for you):
Sigh... no need to be ironic. Wietlol (I think it was him) always tells people to use UnitApplyTimedLife instead of KillUnit, because KillUnit leaks. I suppose it leaks more than 0,04kb, and that's why he's suggesting that to people.
I was just wondering if RemoveUnit has the same issue, or would it be the same as UnitApplyTimedLife. I already knew that removing the unit directly doesn't play its death and decay animations, as well as the death animations of the effects attached to it. For my purposes I don't need these animations, so it wouldn't matter if its simply removed, instead of killed (with timed life).
 

Deleted member 219079

D

Deleted member 219079

He must've witnessed UnitApplyTimedLife() being better than KillUnit() in some way.

Warcraft's memory usage has been inspected and it has been concluded that removing unit leaks. You can do your own research if you want to see if UnitApplyTimedLife is our savior.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
UnitApplyTimedLife() is one way to do it.
If it requires to be instant, use SetWidgetLife(u, 0).

Unit handles arent properly removed hence why every unit will leak 4 bytes?... I dont know the actual number but at least something.

Using KillUnit() has a massive RAM increase when using KillUnit() and immediately RemoveUnit() after that compared to only RemoveUnit().
However, this may be because of death models such as blood etc, but this is not the case for SetWidgetLife(), UnitApplyTimedLife() and UnitDamageTarget().
(This RAM increase is not removed within 10 minutes... I didnt test longer than that.)
 

Deleted member 219079

D

Deleted member 219079

How did you conclude that it's a handle leak
 
UnitApplyTimedLife() is one way to do it.
If it requires to be instant, use SetWidgetLife(u, 0).

Unit handles arent properly removed hence why every unit will leak 4 bytes?... I dont know the actual number but at least something.

Using KillUnit() has a massive RAM increase when using KillUnit() and immediately RemoveUnit() after that compared to only RemoveUnit().
However, this may be because of death models such as blood etc, but this is not the case for SetWidgetLife(), UnitApplyTimedLife() and UnitDamageTarget().
(This RAM increase is not removed within 10 minutes... I didnt test longer than that.)
Can you link to the post where you made that discovery? Or can you provide a testmap? Because this is the first time I heard about that and there is absolutely no way the community would have missed that in over 10 years of Warcraft.


@Topic:
Just to clear up your confusion: Both KillUnit() and RemoveUnit() are fine. We (as in literally everyone except Wietlol) have been using these natives for years and never had any problems. For missiles, use DummyRecycler or MissileRecycler, but that is more a performance thing than for memory reasons.
 
Status
Not open for further replies.
Top