Map lagging? (Over time...zzzz)

ZakkWylde-

New Member
Reaction score
14
Every second, this function creates and orders 2-6 troll headhunters...

JASS:
function yU takes integer Id,real X1,real Y1,real X2,real Y2,real YH returns nothing
    local unit zH=CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), Id, X1, Y1, YH)
    call IssuePointOrderById(zH,851986,X2,Y2)
    call SetUnitMoveSpeed(zH, 370)
    call GroupAddUnit(udg_Level4Pat,zH)
    call GroupAddUnit(udg_Level4Snow, zH)
    set zH = null
endfunction

function ZU takes integer Id,rect r1,rect r2 returns nothing
    local integer i
    local real X1
    local real Y1
    local real X2
    local real Y2
    set i =GetRandomInt(0, 2)
    loop
        exitwhen (i<0)
        set X1=GetRandomReal(GetRectMinX(r1),GetRectMaxX(r1))
        set Y1=GetRandomReal(GetRectMinY(r1),GetRectMaxY(r1))
        set X2=GetRectMaxX(r2)
        set Y2=GetRandomReal(GetRectCenterY(r2),GetRectCenterY(r2))
        call yU(Id,X1,Y1,X2,Y2,0)
        set i=i-1
    endloop
    set i = 0 //Whatever =D
endfunction

function Gogo takes nothing returns nothing
    local integer Th = 'ohun'
    call ZU(Th, gg_rct_Level4BigTrolla, gg_rct_Level4BigTrollaStop)
    call ZU(Th, gg_rct_Level4BigTrollb, gg_rct_Level4BigTrollbStop)
endfunction

//===============
function InitTrig_Level4BigSnow takes nothing returns nothing
    set gg_trg_Level4BigSnow = CreateTrigger()
    call DisableTrigger(gg_trg_Level4BigSnow)
    call TriggerRegisterTimerEvent(gg_trg_Level4BigSnow, 1., true)
    call TriggerAddAction(gg_trg_Level4BigSnow, function Gogo)
endfunction


There's the code. Is there any reason this should cause lag after running for a while?

When the troll headhunters reach the other side, I remove them from the game (using GUI). The units are removed...but is something left behind?
Am I missing something? After about 5 minutes of this running, I believe it single-handedly accounts for about 20-40 fps (out of my normal 60). When it first starts up, its around 10.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Are you use it's that trigger? Try disabling it.
 

ZugZugZealot

New Member
Reaction score
33
Do you remove them from group as well? I know as much removing a unit stored in a variable isn't gone for good until no longer stored. I'm not sure if the same principle applies to unit groups or not.
 

ZakkWylde-

New Member
Reaction score
14
Do you remove them from group as well? I know as much removing a unit stored in a variable isn't gone for good until no longer stored. I'm not sure if the same principle applies to unit groups or not.

That may be the case...? Can anyone verify this?

@cleeezzz, I could combine ZU and yU, but I'm too lazy atm to think through it.
and I just realized [ljass]set Y2=GetRandomReal(GetRectCenterY(r2),GetRectCenterY(r2))[/ljass] is useless....I dunno why I did that...shoulda just been the [ljass]set Y2=GetRectCenterY(r2)[/ljass]
 

ZugZugZealot

New Member
Reaction score
33
Having "benchmarked" with Task manager (Yes, I know it's a crude method), testing two scenarios and looking at War3.exe's memory usage I found that...

JASS:
//Memory usage kept going up with this, indicating memory leak...

scope TestIt initializer Init
    globals
        private trigger trig
        private group uG
    endglobals
    
    private function Actions takes nothing returns nothing
        local unit u
        local integer i
        
        set i = 0
        loop
            exitwhen i > 200
            set u = CreateUnit( Player(1), 'hfoo', 0, 0, 0 )
            call GroupAddUnit( uG, u )
            //call GroupRemoveUnit( uG, u )
            call RemoveUnit(u)
            set i = i + 1
        endloop
        
        set u = null
    endfunction
    
    private function Init takes nothing returns nothing
        local integer i = 0
        set trig = CreateTrigger()
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent( trig, Player(i), EVENT_PLAYER_END_CINEMATIC )
            set i = i + 1
        endloop
        call TriggerAddAction( trig, function Actions )
        set uG = CreateGroup()
    endfunction
endscope


JASS:
//This one stayed approximately the same indicating no memory leak.

scope TestIt initializer Init
    globals
        private trigger trig
        private group uG
    endglobals
    
    private function Actions takes nothing returns nothing
        local unit u
        local integer i
        
        set i = 0
        loop
            exitwhen i > 200
            set u = CreateUnit( Player(1), 'hfoo', 0, 0, 0 )
            call GroupAddUnit( uG, u )
            call GroupRemoveUnit( uG, u )
            call RemoveUnit(u)
            set i = i + 1
        endloop
        
        set u = null
    endfunction
    
    private function Init takes nothing returns nothing
        local integer i = 0
        set trig = CreateTrigger()
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent( trig, Player(i), EVENT_PLAYER_END_CINEMATIC )
            set i = i + 1
        endloop
        call TriggerAddAction( trig, function Actions )
        set uG = CreateGroup()
    endfunction
endscope


Of course the difference between the two, is the leakless one has [ljass]call GroupRemoveUnit( uG, u )[/ljass] while the leaking one doesn't. Which for me is good enough confirmation for me, that [ljass]RemoveUnit()[/ljass] will leave residual data in unit groups unless removed from group as well.

Side note: For the one that leaked, it increased the mem usage of War3.exe by 10 megs from a few ESC presses.
 

ZakkWylde-

New Member
Reaction score
14
I love you =D.

Thanks.
ZZZzz can't give you any more rep until I spread it around... if only other people were helpful (JK =D)
 

Viikuna

No Marlo no game.
Reaction score
265
Removed units ( Removed by either dying or RemoveUnit ) indeed leave ghost reference to group.

This is also the reason why loops with [lJASS]exitwhen FirstOfGroup( group ) == null[/lJASS] can fail, since those ghost references return null.

There is function called GroupRefresh by Captain Griffen to remove ghost references from group. you can find it from GroupUtils system.
 

ZakkWylde-

New Member
Reaction score
14
wouldn't [ljass]call GroupRemoveUnit(udg_Level4Pat, GetEnumUnit())[/ljass] work just as well?

Or are these "ghost references" still left there?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top