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

Leak Related

Status
Not open for further replies.
Level 8
Joined
Mar 26, 2009
Messages
301
Which of those following sitiautions cause leaks:
1-) An unit is stored in variable A. Then this unit dies or is removed via triggers.
Another trigger now issues an order with variable A (to non-existent unit) like:
- Order A to do something
Does this cause a leak (making an action where reference unit no longer exists)
P.S: Variable will be nullified to "no unit" sooner or later. What I am asking here is, when unit is stored in variable A and that unit no longer exists, making an action with that variable cause a leak, or not.

2-) Referring to a point using "Position of Unit X" cause leak?

3-) Referring to region with "Playable Map Area" cause leak?

4-) Does un-nullified item variables cause leak?
 
Level 15
Joined
Oct 16, 2010
Messages
941
1-) An unit is stored in variable A. Then this unit dies or is removed via triggers.
Another trigger now issues an order with variable A (to non-existent unit) like:
- Order A to do something
Does this cause a leak (making an action where reference unit no longer exists)

no, they probably have a null catch somewhere that will prevent the code from being processed if the value is null.

Referring to a point using "Position of Unit X" cause leak?

yes, the BJ that the GUI converts to creates a new location object that is never used again (location objects just store x and y values). You need to destroy the location afterwards or set the wantdestroy variable to true beforehand.

3-) Referring to region with "Playable Map Area" cause leak?

No, playable map area is a pre-defined rect variable (or region I can't remember) and nothing is created when you call this function, it just returns the variable value.

4-) Does un-nullified item variables cause leak?

Well it depends, if your never going to use that item variable again then yes. All a 'leak' is is some memory that has been allocated and is not being used. So if your never going to use that item variable again, then you should null it so the memory is wiped.

hope that all made some sense.
 
Level 8
Joined
Mar 26, 2009
Messages
301
They did =) Thank you =)
Edit:
Wait a minute. To prevent "position of unit" leak, how do I proceed?
I create a point variable and store "position of unit" inside that, then I destroy the variable. Is that it? =) Thanks in advance.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
You Remove the location the variable points to. In JASS you can not remove/detroy variables. Globals must be declared on map initialization in the global area of the script and will last until the game ends. Locals must be decleared at the start of a function and will last until the end of the function is reached.

An unit is stored in variable A. Then this unit dies or is removed via triggers.
Apparently, removing units via triggers is itself a leak. People say that it does not deallocate some of the memory and the handle ID the unit uses. Instead they advise making the unit explode on death and then killing it.
 
Level 15
Joined
Oct 16, 2010
Messages
941
Apparently, removing units via triggers is itself a leak. People say that it does not deallocate some of the memory and the handle ID the unit uses. Instead they advise making the unit explode on death and then killing it.

So the code for exploding units properly cleans up the memory but not the one for removing them? Brilliant...

I really hope Galaxy doesn't have these same problems
 
Level 8
Joined
Mar 26, 2009
Messages
301
To prevent "position of unit" leak, how do I proceed?
I create a point variable and store "position of unit" inside that, then I destroy the variable. Is that it?
I was referring to GUI, not Jass.
Is this a proper method to prevent leaks from occourring:

  • Set Position_Of_Unit[8] = (Position of (Ordered unit))
  • Unit - Create 1 Classic Dummy for (Owner of (Ordered unit)) at Position_Of_Unit[8] facing (Facing of (Ordered unit)) degrees
  • Unit - Add Attack Disable (out of ammo) to (Last created unit)
  • Unit - Set level of Attack Disable (out of ammo) for (Last created unit) to 1
  • Unit - Order (Last created unit) to Neutral Dark Ranger - Silence Position_Of_Unit[8]
  • Custom script: call RemoveLocation (udg_Position_Of_Unit[8])
 
Status
Not open for further replies.
Top