HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Invisible Memory Leak!

06-30-2006, 03:41 PM#1
Thunder_Eye
This code seems to leak like hell, after Ive cast the spell like 10-15 times it starts to chop heavily.
Collapse JASS:
function UnitDamageTargetMJ takes unit caster, unit target, real damage, boolean instant, boolean frost, real frostdur, string hiteffect returns nothing
       local real x1
       local real x2
       local real y1
       local real y2
       local real dist
       local effect eff
    if (instant == false) then
       set x1 = GetUnitX(caster)
       set x2 = GetUnitX(target)
       set y1 = GetUnitY(caster)
       set y2 = GetUnitY(target)
       set dist = SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) / 1000.00
       call TriggerSleepAction(dist)
    endif
    call UnitDamageTarget(caster, target, damage, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, WEAPON_TYPE_WHOKNOWS)
    set eff = AddSpecialEffectTarget( hiteffect, target, "chest" )
    call TriggerSleepAction(0.50)
    call DestroyEffect(eff)
    set eff = null
    set caster=null
    set target=null
endfunction

function Trig_Spells_Necromancer_Actions takes nothing returns nothing
     local unit caster = GetTriggerUnit()
     local unit target = GetSpellTargetUnit()
     local integer abilityid = GetSpellAbilityId()
     if abilityid == 'A006' then //Dark Bolt
         call TriggerSleepAction(0.50)
         call UnitDamageTargetMJ( caster, target, 40, false, false, 0.00, "Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl" )
         set caster = null
         set target = null
         set abilityid = 0
         return
    endif
endfunction

anyone can see any leaks?
06-30-2006, 03:44 PM#2
Rising_Dusk
Collapse JASS:
set caster = null
set target = null

In the second function, you forgot to null the abovementioned.
You dont need to null function arguments either in the first function.

I don't see why it'd get super choppy.
Unless you're calling it A LOT or using very huge SFX or something.
06-30-2006, 03:46 PM#3
Thunder_Eye
doesnt they get nullified by
Collapse JASS:
         set caster = null
         set target = null
         set abilityid = 0
if Dark Bolt is the only spell I cast?
(btw this isnt the whole code, sliced it off after the part which I knows lags)
Here's the whole second function:
Collapse JASS:
function Trig_Spells_Necromancer_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local integer abilityid = GetSpellAbilityId()
    if abilityid == 'A006' then //Dark Bolt
        call TriggerSleepAction(0.50)
        call UnitDamageTargetMJ( caster, target, 40, false, false, 0.00, "Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl" )
        set caster = null
        set target = null
        set abilityid = 0
        return
    elseif abilityid == 'A003' then //
        call funci2(caster, GetUnitAbilityLevel(caster, 'A005'), 1800.00)
        set caster = null
        set target = null
        set abilityid = 0
        return
    elseif abilityid == 'A004' then //
        call funci3(target, GetUnitAbilityLevel(caster, 'A01B'), 30.00)
        set caster = null
        set target = null
        set abilityid = 0 
        return
    elseif abilityid == 'A005' then //
        call DoTMJ(caster, target, 3.00, 5, 40.00, "Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayDamage.mdl", 'A01|')
        set caster = null
        set target = null
        set abilityid = 0
        return
    elseif abilityid == 'A007' then //Summon Nether Dragon
        call SummonNetherDragon(caster)
        set caster = null
        set target = null
        set abilityid = 0
       return
    endif
    set caster = null
    set target = null
    set abilityid = 0
endfunction
(btw yes I know the code sucks, just wanna know what leaks)
06-30-2006, 04:17 PM#4
Captain Griffen
Passed values do not need to be nullified.

I cannot see any other possible reasons for a leak.
06-30-2006, 04:37 PM#5
Thunder_Eye
Oddly enough there is :S
06-30-2006, 06:07 PM#6
Captain Griffen
Quote:
This code seems to leak like hell, after Ive cast the spell like 10-15 times it starts to chop heavily.

That would have to be quite a major leak. That happens in my experience normally when it is a terrain deformation leak, lots of other leaks, or it isn't a leak (or an event 'leak' causing it to happen lots of times).

On balance, I'd say it probably wasn't a leak as such. You're not using test map are you (or having WE open)?
06-30-2006, 06:32 PM#7
Thunder_Eye
Ive been using testmap button for several years with much "laggier" codes and it have never lagged.
06-30-2006, 06:55 PM#8
Rising_Dusk
Restart your computer or something.
Because I can assure you, unless something else happens at roughly the same time that causes lag, this baby won't cause any on its own.
06-30-2006, 06:58 PM#9
Thunder_Eye
Ive already restarting, tested this several times and it only lags after 10-15 casts from the spell.
The first casts causes no lag, then suddenly it gets really choppy
06-30-2006, 06:58 PM#10
PipeDream
Is this being run from a timer callback or in a group loop?
06-30-2006, 07:05 PM#11
Thunder_Eye
huh? it's neither of them, it's just from a normal event (unit casts ability)
EDIT: hmm something is really wrong, even this trigger causes lag after used some time
Trigger:
Untitled Trigger 002
Collapse Events
Unit - A unit Starts the effect of an ability
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Ability being cast) Equal to Shadow Bolt
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Distance between (Position of (Casting unit)) and (Position of (Target unit of ability being cast))) Greater than or equal to 300.00
Collapse Then - Actions
Wait 0.50 seconds
Else - Actions
Wait ((Distance between (Position of (Casting unit)) and (Position of (Target unit of ability being cast))) / 1000.00) seconds
Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing (Random real number between 12.00 and 16.00) damage of attack type Spells and damage type Death
Else - Actions
EDIT2: This is very odd, Ive made some testing without the triggers, the ability makes it lag anyway :S
Ive tested with several other abilities, none of them causes lag.
06-30-2006, 08:22 PM#12
Vexorian
Quote:
EDIT: hmm something is really wrong, even this trigger causes lag after used some time
that could be because of the location leaks...

The JASS code seems to call a lot of custom functions my bet is that the leaks are inside one or more of them
06-30-2006, 08:38 PM#13
Thunder_Eye
Nvm, It is now fixed, got help from Shadow1500, it was an "bug" with the base ability Acid Bomb which by using 0 as duration and damage interval as 0 makes an infinite looping which just stacks and well.. you can figure out the outcome