• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unreviable Hero

Status
Not open for further replies.
Level 5
Joined
Jan 15, 2018
Messages
128
The idea of this trigger is to make a hero unrevivable. I think it leaks though. Would the solution be to add the hero to a unit group and then remove that unit group?

  • BoromirDeath
    • Events
      • Unit - Prince of Gondor 0034 <gen> Dies
    • Conditions
      • ((Current research level of Denethor's Madness for Player 10 (Light Blue)) Equal to 0) or ((Current research level of Reclaim Kingship (Human) for Player 9 (Gray)) Equal to 0)
    • Actions
      • Unit - Remove (Triggering unit) from the game
 
Level 5
Joined
Jan 15, 2018
Messages
128
I thought a leak was removing a unit and the memory of that unit still being in the game.

I guess i thought it should be more complicated.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,503
A leak is when you lose reference to something, therefore you can never remove/destroy it. It will exist in the game's memory forever.

  • Set Variable TempPoint = Center of RegionA
  • Set Variable TempPoint = Center of RegionB
The above trigger leaks a single Point, which is the Point created from the first TempPoint variable (Center of RegionA).

The second usage of TempPoint (Center of RegionB) is not considered a leak yet because we still have a reference to it --> TempPoint.

This means that the second Point can still be removed using:
  • Custom script: call RemoveLocation (udg_TempPoint)

Understand that TempPoint is NOT the Point itself but instead a reference to a Point. (Note: Points are also known as Locations in non-GUI syntax).

Things that don't leak:
Integer, Real, Boolean, String

I've read that Units (and maybe the other types I listed) do technically leak but it's pointless to worry about them.

Long story short, when working in GUI you should really only be focusing on removing these types of leaks:
Unit Groups, Player Groups, Points, Special Effects

Which are cleaned up like so:
  • Custom script: call DestroyGroup(udg_UnitGroupName)
  • Custom script: call DestroyForce(udg_PlayerGroupName)
  • Custom script: call RemoveLocation(udg_PointName)
  • Special Effect - Destroy last created effect
The words Destroy and Remove are basically used interchangeably when it comes to cleaning up leaks.

So with that in mind, your trigger is actually the optimal thing to do because it's REMOVING the Unit, which means that the Unit is being freed from the game's memory. But like I said earlier, you don't need to worry about cleaning up Unit leaks. Units upon dying will Decay and be removed by the game automatically (unless of course you prevent them from decaying). All you've done here is clean up the Unit immediately instead of letting it get cleaned up by... natural causes (if it would be killed) :p

Another case for cleaning up leaks has to do with the use of Local variables. You need to set Local variables to null when you're done using them (integer, real, boolean, and string are excluded from this). Contrary to before, you DO need to null Unit variables and other non-excluded variable types. This is only something to worry about if you're coding in Jass or using local variables with Custom script in your GUI triggers.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Unit removal used to have an internal leak, but this is out of the control of map creators. It occurred no matter how the unit was removed, including naturally from decay or explicitly by the remove unit action. I am unsure if this leak still exists in the current version of Warcraft III. The leak was also trivial and only really a concern for maps that excessively milled tens of thousands units during sessions that lasted many hours.
 
Status
Not open for further replies.
Top