• 🏆 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 leak problem

Status
Not open for further replies.
Level 3
Joined
Aug 18, 2004
Messages
60
I resently downloaded the leak check tool in the tools section to find out why my map was leaking. I found the trigger but I dont know how to change it to the suggested solution! The orignal line was:
(Condition)
Distance between (Position of Vechical[(Integer A)]) and (Position of CS1)) Less than or equal to 500
(Vechical and CS1 are unit vareables)

The suggested fix is
(Suggested fix) Set L= (Position of Vechical [(Integer A)]) and (Position of CS1) Less than or equal to 500
(Suggested fix) Custom Script: Call RemoveLocation(udg_L)

It also says theres a leak on the (Position of CS1) thing. Does anyone know how I fix it?
 
Level 6
Joined
May 19, 2004
Messages
267
Code:
        Set L = (Position of Vechical[(Integer A)])
        Set L2 = (Position of CS1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Distance between L and L2) Less than or equal to 500.00
            Then - Actions
                blabla
            Else - Actions
        Custom script:   call RemoveLocation(udg_L)
        Custom script:   call RemoveLocation(udg_L2)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
LOL you need a leak check tool?
Folow this rule and no locations will leak.

Always attach any locations to variabls before use.
All functions that return locations leak unless you destry the locations.
Always destroy veriables as soon as you have used them.

But I guess for all you GUI fans you need a leak check tool. . .
 
Level 3
Joined
Aug 18, 2004
Messages
60
Question

When you say the set L stuff are you doing that in a diffrent trigger? Also will "removeing" the location make it unusable? Im gona have it runing almost constantly.

Oh and sorry dr super good but this is both the first time I have dealt with leak checks and it will be my first time writeing custom script.
 
Level 5
Joined
Feb 16, 2006
Messages
151
Explaining on the term Memory Leak:
If you create an object, and don't destroy it, that object will plain remain there, doing nothing but take away place.
Take an example on units.
If you create a new unit and don't want to use it anymore, because it was a dummy or w/e, he will remain there forever if you don't remove him, right?
And if you keep creating such one-time-usage units and don't remove them, they will flood over the map, thus making the map lag.
The same thing applies for Locations, and the following objects
JASS:
boolexpr
    call DestroyBoolExpr(someBoolExpr)
conditionfunc
    call DestroyCondition(someConditionFunc)
defeatcondition
    call DestroyDefeatCondition(someDefeatCondition)
effect
    call DestroyEffect(someEffect)
filterfunc
    call DestroyFilter(someFilterFunc)
fogmodifier
    call DestroyFogModifier(someFogModifier)
force
    call DestroyForce(someForce)
group
    call DestroyGroup(someGroup)
image
    call DestroyImage(someImage)
itempool
    call DestroyItemPool(someItemPool)
leaderboard
    call DestroyLeaderboard(someLeaderboard)
lightning
    call DestroyLightning(someLightning)
multiboard
    call DestroyMultiboard(someMultiboard)
quest
    call DestroyQuest(someQuest)
texttag
    call DestroyTextTag(someTextTag)
timer
    call DestroyTimer(someTimer)
timerdialog
    call DestroyTimerDialog(someTimerDialog)
trigger
    call DestroyTrigger(someTrigger)
ubersplat
    call DestroyUbersplat(someUbersplat)
unitpool
    call DestroyUnitPool(someUnitPool)
gamecache
    call FlushGameCache(someGameCache)
unit
    call RemoveUnit(someUnit)
item
    call RemoveItem(someItem)
location
    call RemoveLocation(someLocation)
rect
    call RemoveRect(someRect)
region
    call RemoveRegion(someRegion)
weathereffect
    call RemoveWeatherEffect(someWeatherEffect)
Meaning, if you do want to use that location over and over again, you don't have to destroy(remove) it.
 
Level 3
Joined
Aug 18, 2004
Messages
60
ok but

Ok I get that but if I leave it the way it is, the map gets to lagging so badly that it practicaly freezes after 15 minets. I have it repeating every .10 of a second and there are 3 other triggers almost exactly like it. Mabey theres a better way to do it? The idea is that whenever a starfighter flys close enough to a certain capital ship its given a ability that lets it "land" in the ships hanger. Theres also a triger that removes the ability if the starfighter flys out of range. Any suggestions?
Oh and thanx for the help (all of you).
 
Status
Not open for further replies.
Top