HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Jass: Can't find the Leak...

04-22-2005, 08:20 AM#1
MindWorX
Code:
//===========================================================================
function P1_1Actions takes nothing returns nothing
    set udg_P1_TempPoint[1] = GetUnitLoc(udg_P1_Boss_Unit)
    set udg_P1_TempPoint[2] = PolarProjectionBJ(udg_P1_TempPoint[1], 128.00, udg_P1_Degree[1])
    if ( udg_P1_Degree[1] >= 359.00 ) then
        set udg_P1_Degree[1] = 0.00
    else
        set udg_P1_Degree[1] = ( udg_P1_Degree[1] + 1.00 )
    endif
    call SetUnitPositionLoc( udg_P1_Attached_Unit[1], udg_P1_TempPoint[2] )
    call RemoveLocation( udg_P1_TempPoint[1] )
    call RemoveLocation( udg_P1_TempPoint[2] )
endfunction
//===========================================================================

//===========================================================================
function InitTrig_P1 takes nothing returns nothing
    set udg_P1_Trigger[1] = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( udg_P1_Trigger[1], 0.01 )
    call TriggerAddAction( udg_P1_Trigger[1], function P1_1Actions )
endfunction
//====================================================================
So, this seems to have a memory leak, can anyone enlighten me?
04-22-2005, 10:34 AM#2
KaTTaNa
Your code doesn't seem to leak, but try this and see if it's better.
If it doesn't help try looking elsewhere for the leak.
Code:
//===========================================================================
function P1_1Actions takes nothing returns nothing
    local real x = GetUnitX(udg_P1_Boss_Unit) + Cos(udg_P1_Degree[1]*bj_DEGTORAD)*128.0
    local real y = GetUnitY(udg_P1_Boss_Unit) + Sin(udg_P1_Degree[1]*bj_DEGTORAD)*128.0
    if ( udg_P1_Degree[1] >= 359.00 ) then
        set udg_P1_Degree[1] = 0.00
    else
        set udg_P1_Degree[1] = ( udg_P1_Degree[1] + 1.00 )
    endif
    call SetUnitX( udg_P1_Attached_Unit[1], x )
    call SetUnitY( udg_P1_Attached_Unit[1], y )
endfunction
//===========================================================================

//===========================================================================
function InitTrig_P1 takes nothing returns nothing
    set udg_P1_Trigger[1] = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( udg_P1_Trigger[1], 0.01 )
    call TriggerAddAction( udg_P1_Trigger[1], function P1_1Actions )
endfunction
//====================================================================
04-22-2005, 10:49 AM#3
MindWorX
I'll try that, but i think i've found the problem...

I have 20triggers similar to the one posted..
Now, i remember something about a code :
Code:
call DestroyTrigger( GetTriggeringTrigger() )
Wouldn't the triggers leave enough to create a lag when i have them run so many times? There's a trigger shot about 2000Times per sec...

The trigger runs smooth, but after a while, it begins to lag, and WC3 starts to consume more memory...

As said, i'll try your suggestion, and also try to see if i can get the triggers down to 4 trigger (1 for each player), instead of 20 (5 for each player)...
04-22-2005, 02:52 PM#4
Vexorian
And I thought that making the JASS forum a subforum would prevent this, /moved.

I see no leak in your code, What makes you think that there seems to be a leak? which are the symptons?
04-23-2005, 11:29 PM#5
iNfraNe
Running a trigger will not "create" something that will consume more memory. Once u Destroy a trigger, it means u cant use it any longer, so this is clearly not a good option here.

This trigger has no leaks, but if u do too many actions wc3 might freeze up a little. You said u had alot of triggers like this right? Why... Try putting them all in 1 trigger which has the periodic event.

If it still lags try 0.02 or 0.03 as periodic event.
04-24-2005, 03:27 PM#6
MindWorX
Quote:
Originally Posted by Lord Vexorian
I see no leak in your code, What makes you think that there seems to be a leak? which are the symptons?
WC3 memory usage... The map runs smootly, and after 30min, i can barely exit...
And sorry about wrong forum...

Quote:
Originally Posted by toot
Running a trigger will not "create" something that will consume more memory. Once u Destroy a trigger, it means u cant use it any longer, so this is clearly not a good option here.

This trigger has no leaks, but if u do too many actions wc3 might freeze up a little. You said u had alot of triggers like this right? Why... Try putting them all in 1 trigger which has the periodic event.

If it still lags try 0.02 or 0.03 as periodic event.
Yea, i'll be trying to get it all in a single trigger, to see if it helps...

Btw, to explain what i'm doing...

I have a unit {udg_P1_Boss_Unit}, and i have 5units{udg_P1_Attached_Unit[1 to 5]} moving around it in circles, and i need it to look naturel... I think move orders make them react too slow, and using an infinite loop doesn't move them fast enough to make it look naturel...