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

Question about this leak

Status
Not open for further replies.
Level 7
Joined
Jun 15, 2010
Messages
218
So i just saw somewere that positions in triggers always leak. is that true? i got this ability called arcane explosion, very simple:

  • arcane explosion
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Explosion
    • Actions
      • Unit - Create 1 Dummy (arcane explosion) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Unit - Set level of Arcane Explosion (Dummy) for (Last created unit) to (Level of Arcane Explosion for (Triggering unit))
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
Now im wondering, does this ability leak? and if yes, do i have to make my ability like this?:

  • arcane explosion
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Arcane Explosion
    • Actions
      • Set Arcane_Position = (Position of (Triggering unit))
      • Unit - Create 1 Dummy (arcane explosion) for (Owner of (Triggering unit)) at Arcane_Position facing Default building facing degrees
      • Unit - Add a 1.20 second Generic expiration timer to (Last created unit)
      • Unit - Set level of Arcane Explosion (Dummy) for (Last created unit) to (Level of Arcane Explosion for (Triggering unit))
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
  • Custom script: call RemoveLocation(udg_Arcane_Position)
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
All positions in triggers creat leaks?! What about if you create permanent corpses at random locations in a region, will those still leak?

PS: Sorry if Chasin225 wants I'll create another thread to ask this, it just seemed relevant to topic.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
What about if you create permanent corpses at random locations in a region, will those still leak?
yes they will.

all locations leak, no matter what the cause is.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Locations only leak if you create them and then do not remove them before letting go of them. A leaks is when you allocate resources for use yet never deallocate them after they are no longer needed.

It is perfectly fine to create a global location which gets recycled again and again (you reference the global instead of making a new location) and I recommend you do this when applicible. All other cases it is far better to get the X and Y value directly and give those to the XY native rather than create a new location and passing that.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Locations only leak if you create them and then do not remove them before letting go of them.

That's what I meant. Ofcourse you have to remove them....
This is the case for every location created.
Thanks for elaborating even more though :)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
You do not have to remove locations that will always be used until the map ends (eg a spawn point).

so pre-placed regions do not have to be removed?
ok that's something new to me :O...

I always put them in globals and remove them xD Didn't know you don't need to, thnx ;)
 
Level 8
Joined
Dec 12, 2010
Messages
280
I think he's saying if you use the same exact location over an over till the end of the game you don't have to remove it. I didn't know that either but makes a lot of sense. And regions do leak.

I used to use random point in region for creep spawns. That must of leaked really bad :D
 
Level 20
Joined
Oct 21, 2006
Messages
3,231
It should be logical.

Every time you use a location it automatically creates a new location without deleting the latest one. Thats why you put the location into a variable so that you can have an acces to it and remove it from the game manually. But if you have a location that is used multiple times during the game you might want not to remove it.
 
Level 8
Joined
Dec 12, 2010
Messages
280
Not a new location but a new location ID. In GUI we use point variables so we can remove the location and that frees up the ID so it can be recycled or used again. This also frees up some memory. (a very small amount)

If the same location is used throughout the entire game then there is no need to remove it since freeing up that location ID would only cause the game to have to make a new one every time the trigger ran.

Kinda like running in circles chasin your tail :)
 
Status
Not open for further replies.
Top