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

[Trigger] quick question about location leaks

Status
Not open for further replies.
Level 3
Joined
Jun 23, 2007
Messages
32
i know you have to remove temporary locations when used in order to prevent leaks, but heres my question: if say a for loop assigns a temporary location each time around, do u have to remove the location in the loop, or can u do it after, and still have no leaks??

basically if a long trigger uses the same temporary location variable (but changes it) many times, can u just destroy it at the end? or after each use?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
There are no for-loops in wc3 :p
Anyway, every time you use a point variable you create a Location, which holds x,y coordinates.
The variable itself is just a pointer (which is why you DO NOT NULL GLOBALS OMFG (this is for all those that null globals)), therefor you will need to remove it every time you use it. Notice that you are removing the LOCATION, not the variable (yet again for those people...).
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I think he means For each Integer x do y-loops.
If you want the variable to be differen every loop (like a random point), yes, you have to remove it at the end of the loop i'd say.. i'm not quite sure but works for me :)

It doesn't matter if it is random or anything else. Whenever you declare a point value (set VAR = some point, conditions containing points, reals containing points, anything that uses points) it creates a new object which holds inside it x, y and z values.
The variable (if you used one) is just "pointing" to that object.
If you didn't use a variable you do not have access to that object after it was used (which means the object just stays in the system without you being able to remove it).
 
Status
Not open for further replies.
Top