A Re-used variable. Will it leak?

BcBoy

Active Member
Reaction score
6
I've always been careful with variables & specialeffects. Always removing them. First because i most often don't want the special effect to stay. The second is of course to save memory.

Question:
Will a variable(point) leak if i use it many times?

For an example. Unit X casts an ability. The game Sets Variable Y, point of casting unit.
Next time i casts the spell and Y recieves a new value. Will it somehow store the old one? Or will it automatically destroy the old information completly?
 

Romek

Super Moderator
Reaction score
963
It will leak unless you destroy the location it was pointing to beforehand.
JASS:
call RemoveLocation(udg_<Variable Name>)
 

Wratox1

Member
Reaction score
22
if you set a variable to a value and then set it to a new value it will override the first value, this means that you will have to make a new variable, or make it an array;)
 

BcBoy

Active Member
Reaction score
6
Yes. But i WANT it to override the old value. Since it's the same unit who will cast the same spell, the old information is useless anyway. Otherwise i must make a new variable(or use a LARGE array) for each spellcast wich IMO would take more memory.
 

Nenad

~Choco Coronet~ Omnomnom
Reaction score
137
You can use the same TempPoint (point variable) for every spell if you just null it in the end like Romek said. Reusing Variables is normal (i have about 30-40 triggers in my map that use the same Point Variable). It doesn't leak but you have to remove it everytime you use it (if you don't and just overwrite it it will leak) ^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top