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

[Trigger] memory leaks?

Status
Not open for further replies.
Level 9
Joined
Aug 21, 2008
Messages
533
I think this trigger leaks cause when i use it too often the game beganns to lag.

  • Untitled Trigger 002
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Manastrike
    • Actions
      • Unit - Pause (Casting unit)
      • Set manaamount = ((Mana of (Casting unit)) / 2.00)
      • Unit - Set mana of (Triggering unit) to manaamount
      • Set tempoint[2] = (Position of (Casting unit))
      • Set tempoint[1] = (tempoint[2] offset by 800.00 towards (Facing of (Triggering unit)) degrees)
      • Set real_array[1] = ((Distance between tempoint[1] and tempoint[2]) / 25.00)
      • Unit - Turn collision for (Casting unit) Off
      • Animation - Play (Casting unit)'s attack animation
      • Unit - Make (Casting unit) face tempoint[1] over 0.00 seconds
      • For each (Integer A) from 1 to 25, do (Actions)
        • Loop - Actions
          • Set tempoint[((Integer A) + 2)] = (tempoint[((Integer A) + 1)] offset by real_array[1] towards (Facing of (Casting unit)) degrees)
          • Unit - Move (Casting unit) instantly to tempoint[((Integer A) + 2)], facing tempoint[1]
          • Special Effect - Create a special effect at tempoint[((Integer A) + 1)] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Set special_effect[(Integer A)] = (Last created special effect)
          • Unit Group - Pick every unit in (Units within 250.00 of tempoint[((Integer A) + 1)] matching (((Matching unit) belongs to an ally of (Owner of (Casting unit))) Equal to False)) and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to unitgroup
      • Unit - Unpause (Casting unit)
      • Unit - Turn collision for (Casting unit) On
      • Unit Group - Remove (Casting unit) from unitgroup
      • Unit Group - Pick every unit in unitgroup and do (Actions)
        • Loop - Actions
          • Unit - Cause (Casting unit) to damage (Picked unit), dealing (manaamount x ((Real((Level of (Ability being cast) for (Casting unit)))) / 4.00)) damage of attack type Spells and damage type Normal
      • For each (Integer y) from 1 to 27, do (Actions)
        • Loop - Actions
          • Special Effect - Destroy special_effect[y]
          • Custom script: call RemoveLocation( udg_tempoint[udg_y] )
This is my first spell with more then 2 actions so it could be the only spell which cause the lagg
 

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
Well it leaks HEAVY and it isn't MUI at all and the Loop actions well i see what ur doing great thinking ! ( thought if u are not thinking what i was thinking then u are just Stupid )

  • Untitled Trigger 002
    • Events
    • Unit - A unit Finishes casting an ability
    • Conditions
    • (Ability being cast) Equal to Manastrike
    • Actions
    • Unit - Pause (Casting unit)
    • Set manaamount = ((Mana of (Casting unit)) / 2.00)
    • Unit - Set mana of (Triggering unit) to manaamount
    • Set tempoint[2] = (Position of (Casting unit))
    • Set tempoint[1] = (tempoint[2] offset by 800.00 towards (Facing of (Triggering unit)) degrees)
    • Set real_array[1] = ((Distance between tempoint[1] and tempoint[2]) / 25.00)
    • Unit - Turn collision for (Casting unit) Off
    • Animation - Play (Casting unit)'s attack animation
    • Unit - Make (Casting unit) face tempoint[1] over 0.00 seconds
    • For each (Integer A) from 1 to 25, do (Actions)
    • Loop - Actions
    • Set tempoint[((Integer A) + 2)] = (tempoint[((Integer A) + 1)] offset by real_array[1] towards (Facing of (Casting unit)) degrees)
    • Unit - Move (Casting unit) instantly to tempoint[((Integer A) + 2)], facing tempoint[1]
    • Special Effect - Create a special effect at tempoint[((Integer A) + 1)] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
    • Set special_effect[(Integer A)] = (Last created special effect)
    • [COLOR="Red"]LEAK Unit Group and Locations !!!! [/COLOR]
    • Unit Group - Pick every unit in (Units within 250.00 of tempoint[((Integer A) + 1)] matching (((Matching unit) belongs to an ally of (Owner of (Casting unit))) Equal to False)) and do (Actions)
    • Loop - Actions
    • Unit Group - Add (Picked unit) to unitgroup
    • Unit - Unpause (Casting unit)
    • Unit - Turn collision for (Casting unit) On
    • Unit Group - Remove (Casting unit) from unitgroup
    • Unit Group - Pick every unit in unitgroup and do (Actions)
    • Loop - Actions
    • Unit - Cause (Casting unit) to damage (Picked unit), dealing (manaamount x ((Real((Level of (Ability being cast) for (Casting unit)))) / 4.00)) damage of attack type Spells and damage type Normal
    • For each (Integer y) from 1 to 27, do (Actions)
    • Loop - Actions
    • Special Effect - Destroy special_effect[y]
  • Custom script: call RemoveLocation( udg_tempoint[udg_y] )[
    • COLOR="red"]Remove the location after u Finished destroying the special effects [/COLOR]
IT IS NOT MUI !!!
 
Level 6
Joined
Mar 20, 2008
Messages
208
Special effects will leak, and so will locations when you pick every unit in X area.

I also suggest you double check the second loop. Your first goes from 1 to 25, the other goes from 1 to 27. That may throw up some null pointer errors.
 
Level 9
Joined
Aug 21, 2008
Messages
533
The second loop removes all tempoints and special effects- read carefully. just forgot to remove the unit group...
The second loop have 27 cause there are 27 tempPoints.(they all removed in this loop)
This spell isnt supposed to be mui... wy i should make it mui when only 1 player can controll that hero?:confused:

I ifxed the group:
  • Untitled Trigger 002
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Manastrike
    • Actions
      • Unit - Pause (Casting unit)
      • Set manaamount = ((Mana of (Casting unit)) / 2.00)
      • Unit - Set mana of (Triggering unit) to manaamount
      • Set tempoint[2] = (Position of (Casting unit))
      • Set tempoint[1] = (tempoint[2] offset by 800.00 towards (Facing of (Triggering unit)) degrees)
      • Set real_array[1] = ((Distance between tempoint[1] and tempoint[2]) / 25.00)
      • Unit - Turn collision for (Casting unit) Off
      • Animation - Play (Casting unit)'s attack animation
      • Unit - Make (Casting unit) face tempoint[1] over 0.00 seconds
      • For each (Integer A) from 1 to 25, do (Actions)
        • Loop - Actions
          • Set tempoint[((Integer A) + 2)] = (tempoint[((Integer A) + 1)] offset by real_array[1] towards (Facing of (Casting unit)) degrees)
          • Unit - Move (Casting unit) instantly to tempoint[((Integer A) + 2)], facing tempoint[1]
          • Special Effect - Create a special effect at tempoint[((Integer A) + 1)] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set unitgroup[1] = (Units within 250.00 of tempoint[((Integer A) + 1)])
          • Unit Group - Pick every unit in unitgroup[1] and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to unitgroup[2]
      • Unit - Unpause (Casting unit)
      • Unit - Turn collision for (Casting unit) On
      • Unit Group - Remove (Casting unit) from unitgroup[2]
      • Unit Group - Pick every unit in unitgroup[2] and do (Actions)
        • Loop - Actions
          • Unit - Cause (Casting unit) to damage (Picked unit), dealing (manaamount x ((Real((Level of (Ability being cast) for (Casting unit)))) / 4.00)) damage of attack type Spells and damage type Normal
      • For each (Integer y) from 1 to 27, do (Actions)
        • Loop - Actions
          • Custom script: call RemoveLocation( udg_tempoint[udg_y] )
      • Custom script: call DestroyGroup( udg_unitgroup[1] )
      • Custom script: call DestroyGroup( udg_unitgroup[2] )
edit: Oo it is mui there is no wait. tested with friends we spammed this spell and nobody had a bug O Maybe there is a chance of 1:1000 that ´2 people casting at same time - but it has lng cooldown so it shouldNt be a prob
 
Last edited:
Level 11
Joined
Nov 15, 2007
Messages
781
  • For each (Integer A) from 1 to 25, do (Actions)
  • Loop - Actions
    • Set tempoint[((Integer A) + 2)] = (tempoint[((Integer A) + 1)] offset by real_array[1] towards (Facing of (Casting unit)) degrees)
    • Unit - Move (Casting unit) instantly to tempoint[((Integer A) + 2)], facing tempoint[1]
    • Special Effect - Create a special effect at tempoint[((Integer A) + 1)] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
    • Special Effect - Destroy (Last created special effect)
    • Set unitgroup[1] = (Units within 250.00 of tempoint[((Integer A) + 1)])
    • Unit Group - Pick every unit in unitgroup[1] and do (Actions)
    • Loop - Actions
      • Unit Group - Add (Picked unit) to unitgroup[2]
You need to destroy your variables at the end of the loop or they'll be overwritten repeatedly. That's where your leak is coming from. Also the last unit group actions seem unnecessary...?
 
Level 9
Joined
Aug 21, 2008
Messages
533
first unit gruo is tempoary and is overwritten evry time the loop makes it work^^ The 2cond one stores all the units togheter . Cause of the add i dont have any unit twice.
So without the second only the units which are near the impact of the caster would get damaged
i destroy the regions at end of trigger cause there 2 regions to much for the first loop.
 
Level 11
Joined
Nov 15, 2007
Messages
781
Okay, but just because you do something for a reason doesn't mean it won't leak. Sorry :nw: You need to destroy unitgroup[1] every time the loop runs.
 
Level 8
Joined
Feb 20, 2007
Messages
338
It is my humble understanding that nothing is overwritten and destroyed - instead everything is added to the memory until it is specifically destroyed via a custom script such as:
  • Custom script: call DestroyGroup( udg_unitgroup[2] )
Each time a thing is called is is recreated, and remains until the game is ended unless you specifically call it and remove it.

Yes there is a certain logic to the concept that if you call the same thing and change its parameters or as you say 'over write' it that the previous instance it was used would destroy it. However the infallible Wizards of Blizzard did not design the editor nor the trigger functions to run a cantrip clean spell after each use. ;-)

Heck, they didn't even include in GUI a simple trigger function "Point - Remove last created point" which would, in my most humble opinions, make a lot of things far, far easier.
 
Level 6
Joined
Mar 20, 2008
Messages
208
I overwite... wy i should destroy it? If i overwite something it cant leak... well the last overwritten would leak but i destryed it.

There is no overriding done at all, you are just redirecting the pointers while the data still sits in memory.

x---->[u1]

goes to

x---- [u1]
......|---->[u2]

It works that way for any programming language.
 
Status
Not open for further replies.
Top