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

[General] Memory leaks.

Status
Not open for further replies.
Level 8
Joined
Feb 11, 2016
Messages
232
Greetings. I made trigger and want it without memory leak if possible. I want to use same variables in multiple triggers. Also I want to make this works multiple times at once when needed.


Events
Unit - A unit Finishes casting an ability

Conditions
(Ability being cast) Equal to Transition

Actions
Set Vracanje_mesto = (Position of (Casting unit))
Unit - Create 1 Freza Madjija for (Owner of (Casting unit)) at Vracanje_mesto facing (Facing of (Casting unit)) degrees
Custom script: call RemoveLocation (udg_Vracanje_mesto)
Set Freza_Madjija = (Last created unit)
Unit - Order Freza_Madjija to Human Sorceress - Invisibility (Casting unit)
Wait 0,40 game-time seconds
Unit - Remove Freza_Madjija from the game


I know that I should use timer instead of wait but I will do it one day, not now.

In advice thank You <3.
 
Then you need to use locals,

  • Events
    • Unit - A unit Finishes casting an ability
  • Conditions
    • (Ability being cast) Equal to Transition
  • Actions
    • Custom Script: local unit spawn
    • Set Vracanje_mesto = (Position of (Casting unit))
    • Unit - Create 1 Freza Madjija for (Owner of (Casting unit)) at Vracanje_mesto facing (Facing of (Casting unit)) degrees
    • Custom script: Set spawn =bj_lastCreatedUnit
    • Custom script: call RemoveLocation (udg_Vracanje_mesto)
    • Set Freza_Madjija = (Last created unit)
    • Unit - Order Freza_Madjija to Human Sorceress - Invisibility (Casting unit)
    • Wait 0,40 game-time seconds
    • Custom Script: call RemoveUnit(spawn)
    • Custom Script: set spawn = null
    • Custom Script: set udg_Vracanje_mesto = null
    • Custom script: set udg_Freezer_madjija = null
Something like that, i do not have the editor right here.
Not quite sure if RemoveLocation is the same as setting it to null.
 
Last edited:
Level 8
Joined
Feb 11, 2016
Messages
232
Aham, okay, now I check that I do not need wait function. So that change something? Will be okay if I from My trigger just remove that wait time without making it as you said? I mean I do not want to make something messy then after don't know how to find and fix a mistake.
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
That's because The_Silent typed Custom Script instead of Custom script, and the vB code used to show triggers on this site is case-sensitive. It looks reads the text before the - to see what symbol it should show there.
  • Custom script: do something
  • Custom Script: do something
  • -------- another example --------
  • Unit Group - Pick...
  • Unit group - Pick...
 
Status
Not open for further replies.
Top