• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

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)
 
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.
 
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 ;)
 
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
 
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.
 
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.
Back
Top