• 🏆 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!

When do Variable Leaks Occour?

Status
Not open for further replies.
Level 8
Joined
Mar 26, 2009
Messages
301
Me an my friend were discussing; he says whenever a appointed variable is used, you need to nullfy the variable and re-appoint it (everytime). Read it very CAREFULLY; it is not that he is talking about appointing same variable to different value without putting nullfy trigger commands (via custom scripts) or anything.

For Ex:
Set "VariableUnit" = Triggering Unit
Move "VariableUnit" to blah blah
Wait 2 seconds
Move "VariableUnit" to "another location"

So we used the same unit variable without any nullfy action between them. Does this cause leak?? Or does that happen with any other variable type, such as a point variable?

Example for this:
Set "Point" = Target Point of Ability Being Cast
Move Triggering Unit to "Point"
Create SFX at "Point"

In this case, we used same point variable in two different actions. Does that cause leak?
 
Last edited:
Level 6
Joined
Aug 22, 2008
Messages
123
Me an my friend were discussing; he says whenever a appointed variable is used, you need to nullfy the variable and re-appoint it. Read very CAREFULLY; it is not that he is talking about appointing same variable to different values without putting nullfy lines (via custom scripts) or anything.

For Ex:
Set Variable = Triggering Unit
Move "VariableUnit" to blah blah
Wait 2 seconds
Move "VariableUnit" to "another location"

So we used the same unit variable without nullfying between them. This cause leak?? Or does that happen with any other variable type, such as point variables?

Example for this:
Set "Point" = Target Point of Ability Being Cast
Move Triggering Unit to "Point"
Create SFX at "Point"

In this case, we used same point variable in different actions. Does that cause leak?

Units in general do not leak, since Blizzard did some good work on that point. Using the value of one variable multiple times is just what they are supposed to be used for and of course that itself does not leak. Leaks appear when there are no pointers to the object left, but the object itself still exists. Having no pointers is quite the same as having no variables left to refer that object.
The main leak-related issues in Warcraft are locations and unit groups. Keep in mind, that multiple variables may reference the same object.:wink:
 
Level 8
Joined
Mar 26, 2009
Messages
301
Edited original post for grammer purposes. About what you say; "Leaks appear when there are no pointers to the object left, but the object itself still exists." What do you mean by existense of object? You mean the variable stored for the object or the real object on the map (such as a footman unit) If that's the case, how do you explain the same matter with point variables? And here is a anoter example for Point and Unit type of variables:
  • Unit - Move Axestorm_Caster instantly to ((Position of Axestorm_Caster) offset by 5.00 towards (Angle from (Position of Axestorm_Caster) to Axestorm_Target_Location) degrees), facing (Angle from Axestorm_Caster_Location to Axestorm_Target_Location) degrees
Now there are three variables in this action above:
- 1 Unit,
- 2 Point variables. And this action is executed with a 0.01 seconds periodic timed event. And the last; this variables will cause leak by taking additional space in memory every 0.01 seconds? (The million dollar question)

And another question: We do some actions on a nullified unit variable (ordering a nullified unit variable to cast a spell for e.g.) Does that cause leak?
 
Last edited:
Level 14
Joined
Aug 31, 2009
Messages
775
If you move something to a point, a leak is created.

The reason being, the point exists, but no variable points to it to tell the system where the hell this point is in the memory.

So, if you say,
  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable Map Area)) facing default building degrees
Then a leak is created.
Why? Because the point that was created, the center of the Playable map area, is now lost as no variable is pointing at it.

As such, always define your point first
  • Set temppoint = (Center of (Playable map area))
Do whatever actions you want to do with this point. Then remove the point.
  • Custom script: call RemoveLocation(udg_temppoint)
Now, the leak is removed.

Units do not leak, neither do any number related variables.

But points and unit groups are by far to most often occurring and most memory problem causing.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Edited original post for grammer purposes. About what you say; "Leaks appear when there are no pointers to the object left, but the object itself still exists." What do you mean by existense of object? You mean the variable stored for the object or the real object on the map (such as a footman unit) If that's the case, how do you explain the same matter with point variables? And here is a anoter example for Point and Unit type of variables:
  • Unit - Move Axestorm_Caster instantly to ((Position of Axestorm_Caster) offset by 5.00 towards (Angle from (Position of Axestorm_Caster) to Axestorm_Target_Location) degrees), facing (Angle from Axestorm_Caster_Location to Axestorm_Target_Location) degrees
Now there are three variables in this action above:
- 1 Unit,
- 2 Point variables. And this action is executed with a 0.01 seconds periodic timed event. And the last; this variables will cause leak by taking additional space in memory every 0.01 seconds? (The million dollar question)

And another question: We do some actions on a nullified unit variable (ordering a nullified unit variable to cast a spell for e.g.) Does that cause leak?

wow thats gonna b massive lag for teh loose 0.o!
do wat damage said and you will probably not get disconnected when trying to start the game on bnet :D

and for your other question: does it work :S???

I don't know if it leaks but would be strange if it worked 0.o!

your telling no unit to cast a spell how can that not go wrong? :S
 
Level 14
Joined
Aug 31, 2009
Messages
775
In addition to what I said earlier, making a "move unit instantly to point" trigger run any faster than 0.02 seconds will make it laggy beyond all comprehension as well as moving "too smooth for your eyes to see". A 0.03 periodic is usually good enough, as your eyes really can't tell the difference between 0.01 and 0.03 anyway, and it'd reduce the lag a fair bit too.
 
Level 8
Joined
Aug 2, 2006
Messages
346
.02 is as fast as you should ever have it. You should only really go as low as .02 if you use JASS and have very few function calls. (ie, eliminate the BJs... no not blowjobs, that's functions defined in Blizzard.j)
 
Status
Not open for further replies.
Top