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

Things That Leak

Level 11
Joined
Dec 31, 2007
Messages
780
two things... the first one...

you gotta wait for the unit to dye... if you wait for 1 second it will work and warcraft wont crash...

now... if you use the dying unit life the dragon will have 0 life... so it will die and another dragon will come out... and then another and another... every spawned dragon will die ...

even thou... i think you were talking about the crash :p
 
Level 6
Joined
Jun 14, 2008
Messages
176
well, that depends

if you set the variable in another trigger, it wont leak(since you use the same memory several times)

but if you re-define the same variable over and over, it will leak

Ok thanks.

Though, what if I have a trigger that redefine the variable a couple of times, then finally remove it?

Also, where can I find a list of or what are all the JASS triggers that destroy/remove stuff like variables? I know the location removing one, what are the others(like for units variables)?


This is a little off topic, but what causes a map to load faster/slower? I know the "Map Init" triggers can cause the loading time to take longer, and having more units preplaced does also.

Does having more stuff in "Object Editor/Data" means the map have to load the the stuff and take a lot longer to load.
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
many things cause the loading time to be longer. Practicly anything you add in the map will cause the loading time to be longer

check out the very first post of this thread. There are many custom scripts there to remove leaks

to make a trigger leakless, you have to remove the leak every time you redefine it

if i redefine TempPoint 4 times in a trigger, i have to destroy the TempPoint 4 times(and before i redefine it every time)
 
Level 6
Joined
Jun 14, 2008
Messages
176
Ok thanks, had a couple of spells that defined a variable multiple times and only removing it only once. I'll fix that.


I need help with something, I am trying to remove Unit variables, I have something like this:

  • Phoneix Charge
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Phoenix Charge (Panda)
    • Actions
      • Set PhoenixChargeHeroPoint = (Position of Pandaren Fire Knight 0112 <gen>)
      • Set PhoenixChargeCastPoint = (Target point of ability being cast)
      • Unit - Create 1 Phoenix Charge Caster (Healing) for (Triggering player) at PhoenixChargeHeroPoint facing PhoenixChargeCastPoint
      • Set PhoenixChargeCasterHealing = (Last created unit)
      • Unit - Create 1 Phoenix Charge Caster (Damage) for (Triggering player) at PhoenixChargeHeroPoint facing PhoenixChargeCastPoint
      • Set PhoenixChargeCasterDamage = (Last created unit)
      • AI - Ignore PhoenixChargeCasterDamage's guard position
      • AI - Ignore PhoenixChargeCasterHealing's guard position
      • Unit - Set level of Phoenix Healing Flames for PhoenixChargeCasterHealing to (Level of Phoenix Charge (Panda) for (Triggering unit))
      • Unit - Set level of Phoenix Damage Flames for PhoenixChargeCasterDamage to (Level of Phoenix Charge (Panda) for (Triggering unit))
      • Unit - Order PhoenixChargeCasterHealing to Neutral Beastmaster - Stampede PhoenixChargeCastPoint
      • Unit - Order PhoenixChargeCasterDamage to Neutral Beastmaster - Stampede PhoenixChargeCastPoint
      • Wait 8.00 seconds
      • Custom script: call RemoveLocation(udg_PhoenixChargeHeroPoint)
      • Custom script: call RemoveLocation(udg_PhoenixChargeCastPoint)
      • Unit - Remove PhoenixChargeCasterHealing from the game
      • Custom script: call DestroyGroup(udg_PhoenixChargeCasterHealing)
      • Unit - Remove PhoenixChargeCasterDamage from the game
      • Custom script: call DestroyGroup(udg_PhoenixChargeCasterDamage)
Last 3 lines, I get compile errors when I try to save, anyone have any ideas on what I should do?
 
Level 11
Joined
Dec 31, 2007
Messages
780
This is a little off topic, but what causes a map to load faster/slower? I know the "Map Init" triggers can cause the loading time to take longer, and having more units preplaced does also.

if you have pre-placed heroes with full skills (i mean... if you have the real heroes you will use in-game already placed in the map) that will take a lot to load... replace your heroes with skills for units with no skills and that will lower the loading time... at least... i did that and it helped me a lot (i had 50+ pre-placed heroes with 5 skills on the map :p)
 
Level 6
Joined
Jun 14, 2008
Messages
176
if you have pre-placed heroes with full skills (i mean... if you have the real heroes you will use in-game already placed in the map) that will take a lot to load... replace your heroes with skills for units with no skills and that will lower the loading time... at least... i did that and it helped me a lot (i had 50+ pre-placed heroes with 5 skills on the map :p)

Hmm, that'd be too bad for me in my case. A lot of the heroes are already preplaced, the hero selection is based off of that. Not only that, tons of triggers are based on the preplaced heroes.

I'm a little too lazy to redo any of that.

newuser, those two last Custom Scripts are used to destroy Unit Groups, not units :p
Thanks, I didn't know. So do I need to use some custom script to remove a single unit variable? What's the single unit variable removal custom script if there is one?
 
Level 11
Joined
Dec 31, 2007
Messages
780
Hmm, that'd be too bad for me in my case. A lot of the heroes are already preplaced, the hero selection is based off of that. Not only that, tons of triggers are based on the preplaced heroes.

I'm a little too lazy to redo any of that.

yeah... i know... i had the same problem... but i have most of it made from variables ... so it wasnt so exhaustive... anyways... its gonna be a hard time to do so but if you have many heroes it is worthy...
 
Level 11
Joined
Dec 31, 2007
Messages
780
my problem posted in page 26 has been solved... like this

While my "If" waits for the "wait for condition" action the condition involving the if is accomplished... because of that the variables are overwritten without being removed (coz it waits for the condition) that is what generates a leak in my trigger... and a very nice one :p

there are 2 ways to solve that... disabling the trigger when it enters the "else" where it waits for the condition... or remaking the trigger the way i did :p

thx for the ideas guys ^^
 
Does this leak?

  • Heart of Venom
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacking unit) has an item of type Heart of Venom |cffffcc00[Rank 1]|r) Equal to True
        • Then - Actions
          • Set HeartofVenom = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HeartofVenom Less than or equal to 6
            • Then - Actions
              • Set HeartofVenompos = (Position of (Attacking unit))
              • Unit - Create 1 Dummy (Heart of Venom) for (Owner of (Attacking unit)) at HeartofVenompos facing Default building facing degrees
              • Unit - Set level of Heart of Venom for (Last created unit) to 1
              • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike (Attacked unit)
              • Custom script: call RemoveLocation(udg_HeartofVenompos)
            • Else - Actions
        • Else - Actions
 
Level 6
Joined
Jun 14, 2008
Messages
176
yeah... i know... i had the same problem... but i have most of it made from variables ... so it wasnt so exhaustive... anyways... its gonna be a hard time to do so but if you have many heroes it is worthy...

Speaking of that, for events such as "A <specific unit> takes damage" or "A <specific unit> is atttacked", how do I make a variable for that? I tried just a "unit variable", it doesn't work.

I am currently using preplaced units for those things but which variables do I use for those triggers?

Also I just noticed(after playing the map recently again) that DotA's loading time sure is ridiculously fast(just 5 second loading time), not to mention the map isn't laggy at the beginning either. The map is nearly 5 MB in size too.

I wonder how they do it? Just by making it so the triggered(for a specific hero) are loaded after they are picked and not using any preplaced units?

The map loading time in the old 5.3x versions was around 3-4 minutes btw, and it was only about 1MB.


Also, my map crashed and gave a fatal error midgame. I didn't really change it much, but does anyone know the common things that causes game crashes/fatal error?
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
Crashes / Fatal Errors usually occur when an so-called "Infinite Loop" occurs, like, a trigger that runs itself when its run(like, A unit dies -> Run (Trigger X))

for using Specific Unit Events, you are going to have to use the "Trigger - Add Event" action in another trigger, but there is something you should know

when using this, you can either use a Event Response or a Variable, but, if you use, lets say, a variable called UnitHero(which is a Unit Variable), it will create an event with the unit which currently is UnitHero, and not the variable. An example is this

Set UnitHero = Paladin 0000
Trigger - Add (UnitHero takes damage) to DamageTrigger
Set UnitHero = Paladin 0001

now "DamageTrigger" will run when Paladin 0000 takes damage, not when UnitHero takes damage
 
Level 11
Joined
Dec 31, 2007
Messages
780
for using Specific Unit Events, you are going to have to use the "Trigger - Add Event" action in another trigger, but there is something you should know

when using this, you can either use a Event Response or a Variable, but, if you use, lets say, a variable called UnitHero(which is a Unit Variable), it will create an event with the unit which currently is UnitHero, and not the variable. An example is this

Set UnitHero = Paladin 0000
Trigger - Add (UnitHero takes damage) to DamageTrigger
Set UnitHero = Paladin 0001

now "DamageTrigger" will run when Paladin 0000 takes damage, not when UnitHero takes damage

im really interested in this... but... is this better explained somewhere?... or should i ask you to explain me by pm?

btw... i would like to make this "unit takes damage" but for every unit in the map when they are attacked by an specific unit that is not pre-placed on the map... is this possible in gui? or i need a jasser?
 
Level 12
Joined
Aug 18, 2006
Messages
1,193
possible in GUI, and i can explain it to you better by pm if you wish

the trigger in GUI would look something like this

  • Damage
  • Events
    • Unit - A unit Is attacked
  • Conditions
    • ((Attacking unit) equal to Whatever)
    • (((Attacked unit) is in DamageGroup) Not equal to True
  • Actions
    • Unit Group - Add (Attacked unit) to DamageGroup
    • Trigger - Add ((Attacked unit) takes damage) to DamageExecute
 
Level 11
Joined
Dec 31, 2007
Messages
780
well... ive been playing with it a while... and it seems that i got the idea ^^ thx for that one... the only thing is a bug that came to my mind... if the damaging hero is ranged, has a nice range and a nice attack speed... the variable will be overwritten before the damage is actually dealt (the missile hits the target)... any idea? guess that this will only work for melee heroes for me :p
 
Level 11
Joined
Jun 21, 2007
Messages
505
Kkots needs help again. Please help him! He forgot how to remove regions from the game.

Why do I need that?

At my cinematic, a knight moves to a specific region every period of time. The map has three triggers, I checked all three, but there was no function calling that knight to move to the wrong region.

I suppose that destroying the region itself would... crash the game. Though, removing the knight and creating it again doesn't help. Oh and there's another knight that stands still where I need it.

I also tried to make an every 0.50 sec. trigger that orders the knights to move to their current regions that I store at a variable. You won't believe, but it didn't help too!

Remaking the trigger would fix the knight, but it took me two days to make it and a half day to make it again, when I remade it in hope that'll help.

Any idea what the function for destroying a region would be?

P.S. Here's the map. Test it.
 

Attachments

  • Time Killer - The Old Castle.w3x
    138.7 KB · Views: 101
Last edited:
Level 6
Joined
Jun 14, 2008
Messages
176
Razorbrain - Thanks for help.

Now another problem - I have a trigger with a player group:
  • Click Unit
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
    • Conditions
      • (Triggering unit) Equal to Unit <gen>
    • Actions
      • Game - Display to (Player group((Triggering player))) the text:
So it leaks right?

I tried fixing by:
  • Click Unit
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
    • Conditions
      • (Triggering unit) Equal to Unit <gen>
    • Actions
      • Set ActiveTriggerPlayer = (Triggering player)
      • Set ActiveTriggeringGroup = (Player group(ActiveTriggerPlayer))
      • Game - Display to ActiveTriggeringGroup the text:
      • Custom script: call DestroyForce(udg_ActiveTriggeringGroup)
Leak checker still says that it's a leak, and it's suggestion doesn't help(it said "Set ActiveTriggeringGroup = (Player group(ActiveTriggerPlayer))" was a leak, then it said to fix that, do the same thing as what it said was a leak.

Is it a bug in leak checker or does it actually still leak?


Also, another question:If I store a point in a variable, create a unit in position of the variable, then remove the variable, then set the same variable to another point and order the last created unit to move to that variable then remove it the variable; all without wait triggers, will that still work?
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
Also, another question:If I store a point in a variable, create a unit in position of the variable, then remove the variable, then set the same variable to another point and order the last created unit to move to that variable then remove it the variable; all without wait triggers, will that still work?

As Razorbrain said: it will work, but a slightly more efficient way would be to move the point variable.
P.s. Don't remember if possible in GUI though.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
All forces leak
Btw
ActivePlayer = Triggering Player is useless
ActiveForce = Force from (Triggering Player) would be fine
or just use DisplayTextToPlayerTimed or whatever that function is
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
"references" are just pointers.
They are not handles.
You remove/destroy handles.
You null pointers that point to handles.
Since Last created unit is a global variable and will be changed next time it is used, there is no need to null it.
No global variables need be to nulled. They only have to be removed/destroyed.
 
Level 6
Joined
Jun 14, 2008
Messages
176
Leak Checker says array points leak if they're set to a "Region <gen> or "Position of Unit"(with no variable), is that true or just a bug?

  • Set ArenaRandom[(Player number of (Owner of (Picked unit)))] = (Random point in Arena <gen>)
  • Set ArenaRandom[(Player number of (Owner of (Picked unit)))] = ^Leak
  • (Suggested Fix) Set MyLocation = (Random point in Arena <gen>)
  • (Suggested Fix) Set ArenaRandom[(Player number of (Owner of (Picked unit)))] = MyLocation <gen>)
  • (Suggested Fix) Custom script: call RemoveLocation(udg_MyLocation)
It suggests me to first set the random point to a variable with no array, then to set the variable with an array set to the variable with no array set to the random point to avoid the leak.

Do I need to do that(set a variable with an a array, to a variable with no array, to a point I want to set) or could I just set a variable with an array to point without leaking?
 
Level 12
Joined
Aug 20, 2007
Messages
866
Leaks are pieces of memory that have not been removed. Shifting it from variable to array cannot remove it. What it can do, is clear the counters on the handles, allowing them to be cleared. This means setting variables to something else when your done with the handle/point/region (etc.). Generally, you set it to "null" or nothing (Custom Script: set udg_YOURVARIABLEGOESHERE = null)

You can set any variable to any handle of its type, regardless of being an array or not, as long as you null the variable and destroy the handle after use.
 
Level 11
Joined
Dec 31, 2007
Messages
780
when you reffer to a point in region you should set that point into a variable (array or not) and then remove via the
  • call RemoveLocation(udg_Your_variable_here[Your_ArrayNumber_here])
if it is not an array use the
  • call RemoveLocation(udg_Your_variable_here)
do you know how to use custom text?
 
Level 6
Joined
Feb 12, 2008
Messages
207
hi, sorry for not reading all 30 pages, i just want to know if this is possible, or i MUST store the unit group into a variable and then destroy it in order to clean leaks on my map.

  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) has buff Starving ) Equal to True
        • Then - Actions
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 1.00)
        • Else - Actions
          • Do nothing
 
Level 11
Joined
Dec 31, 2007
Messages
780
you MUST destroy unit groups...

TIP: instead of using an IF inside the unit group make it above

Unit group: pick every unit in playable map area matching (matching unit has buff starving equal to true)

use "unit in region matching condition" the condition is a boolean one
 
Level 6
Joined
Feb 12, 2008
Messages
207
ok, thanks for the optimizing tip ^^

anyway, if i had to use more than 1 action; i mean, when "Pick every unit in unit group and do - multiple actions" is really needed... can i use "Custom script: set bj_wantDestroyGroup = true"? or i should store the unit group into a variable and then destroy it by using "Custom script: call DestroyGroup (udg_Tent_Group)"?
 
Top