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

Region Variables leak?

Status
Not open for further replies.
Level 8
Joined
Feb 17, 2007
Messages
368
Does this leak if I set the regions as variables and then create units in the region variables? I don't see any way to remove region variables like point 1's, so I'm assuming they dont.

  • Set InitStartSpot = Region 003 <gen>
  • Unit - Create 1 Current_Hero[(Player number of (Triggering player))] for (Triggering player) at (Center of InitStartSpot) facing Default building facing degrees
 
Yeah, regions will leak if they serve no purpose after they are used. If you keep using them in the map, they are fine to keep. But if you are done with using one, then use this (for default regions made using the region editor):
  • Custom script: call RemoveRect(gg_rct_REGIONNAME)
Replace REGIONNAME with the name of your region (eg: call RemoveRect(gg_rct_Region_003)), use underscores "_" if there are spaces.

For this:
  • Unit - Create 1 Current_Hero[(Player number of (Triggering player))] for (Triggering player) at (Center of InitStartSpot) facing Default building facing degrees
It still leaks, you have to make a location variable and have it something like this:
  • Set LocVar = Center of Region 003 <gen>
  • Unit - Create 1 Current_Hero[(Player number of (Triggering player))] for (Triggering player) at LocVar facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_LocVar)
And that should fix it. Generally, you do not need to set variables to regions, and usually there is no need to remove them. If you reference them using something like Center of <Region>, then you will need to set that and remove it. :)
 
Level 5
Joined
Feb 21, 2009
Messages
136
Does this leak if I set the regions as variables and then create units in the region variables? I don't see any way to remove region variables like point 1's, so I'm assuming they dont.

  • Set InitStartSpot = Region 003 <gen>
  • Unit - Create 1 Current_Hero[(Player number of (Triggering player))] for (Triggering player) at (Center of InitStartSpot) facing Default building facing degrees

You don't make any region with Set InitStartSpot = Region 003 <gen> but you just assign a var to a region, so there is nothing to remove AFAIK

tl;dr: no they don't
 
Level 8
Joined
Feb 17, 2007
Messages
368
Yeah, regions will leak if they serve no purpose after they are used. If you keep using them in the map, they are fine to keep. But if you are done with using one, then use this (for default regions made using the region editor):
  • Custom script: call RemoveRect(gg_rct_REGIONNAME)
Replace REGIONNAME with the name of your region (eg: call RemoveRect(gg_rct_Region_003)), use underscores "_" if there are spaces.

For this:
  • Unit - Create 1 Current_Hero[(Player number of (Triggering player))] for (Triggering player) at (Center of InitStartSpot) facing Default building facing degrees
It still leaks, you have to make a location variable and have it something like this:
  • Set LocVar = Center of Region 003 <gen>
  • Unit - Create 1 Current_Hero[(Player number of (Triggering player))] for (Triggering player) at LocVar facing Default building facing degrees
  • Custom script: call RemoveLocation(udg_LocVar)
And that should fix it. Generally, you do not need to set variables to regions, and usually there is no need to remove them. If you reference them using something like Center of <Region>, then you will need to set that and remove it. :)

Ah I see. So I should just go ahead and change all the region variables to points? Ok lol, this will take a bit of time, arghhh, haha.
 
Level 8
Joined
Feb 17, 2007
Messages
368
Do I have to immeadiately clear the leak afterwords? Or can I clear it at the end when all the triggers that use the point are done:

  • Actions
    • Floating Text - Create floating text that reads |cff708090**|r|cfff... at BuuFloatTxtPos with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
    • Floating Text - Change (Last created floating text): Disable permanence
    • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
    • Floating Text - Set the velocity of (Last created floating text) to 30.00 towards 90.00 degrees
    • Custom script: call RemoveLocation (udg_BuuFloatTxtPos)
    • Sound - Play GryphonAviaryWhat1 <gen>
    • Wait 2.00 seconds
    • Unit - Pause Buu
    • Animation - Play Buu's spell animation
    • Set Buu_spit_region = (Random point in Region 089 <gen>)
    • Unit - Create 1 Buu_spit_bomb for Player 12 (Brown) at Buu_spit_region facing Default building facing degrees
    • Unit - Make Buu face (Position of (Last created unit)) over 0.30 seconds
    • Set BuuSEUnit[1] = (Last created unit)
    • Wait 0.50 seconds
    • Animation - Play Buu's spell animation
    • Unit - Create 1 Buu_spit_bomb for Player 12 (Brown) at Buu_spit_region facing Default building facing degrees
    • Unit - Make Buu face (Position of (Last created unit)) over 0.30 seconds
    • Set BuuSEUnit[2] = (Last created unit)
    • Wait 0.50 seconds
    • Animation - Play Buu's spell animation
    • Unit - Create 1 Buu_spit_bomb for Player 12 (Brown) at Buu_spit_region facing Default building facing degrees
    • Custom script: call RemoveLocation (udg_Buu_spit_region)
 
You can't do it at the end in that case, you can only do it at the end if the following conditions are met:
  • Make sure you clean the leak after it is used if you are going to reuse it later on in the trigger.
  • Do not clear it after waits. If you do, then it does have a chance of being cleared and fine, but it also has a chance of not being cleared. If the trigger happens to run again during one of the waits, then the value of the variable may be set to something else, so that variable will be cleared instead.

You can read a memory leak tutorial on this site for more info on the fixes. :)
 
Status
Not open for further replies.
Top