HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Accumulative lag without handle memory leaks?

07-20-2006, 03:55 PM#1
Anitarf
I have a heavily triggered map that causes the game's framerate to gradualy drop as the map is played, making it unplayable after a few minutes of gameplay. The lag must be trigger related, because lowering the main game's trigger frequency from 50hz to 33hz increases the ammount of time it takes for the map to start lagging. However, I have not been able to confirm the existance of a handle leak.
Trigger:
Untitled Trigger 001
Collapse Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Collapse Actions
Custom script: call SetTableBoolean("GlobalVars", "debug", true)
Collapse JASS:
    ...
    local location stupid = Location(VectorGetX(uLoc), VectorGetY(uLoc))

    if GetTableBoolean("GlobalVars", "debug") then
        call SetTableBoolean("GlobalVars", "debug", false)
        call GameMessageAdd(p, I2S(CS_H2I(stupid)), 10.0)
    endif
    ...
The following code causes the handle index of some location that is used by the code to be displayed whenever I press escape. The index remains within certain bounds, and is not increasing over time which would suggest a handle index leak. The map supposedly does have a minor exit time, though, on a PC weaker than mine, I haven't noticed it myself though.

Could string leaks be a problem? I try not to generate too many unique strings, the problem could be the multiboard clock because it's the only string that updates with the main periodic trigger, but that's why I made it multiple strings, one for each digit, calculating them independantly, so I really don't think that I'm generating particularly many unique strings.

So, what other leaks could I have? What could cause the game's framerate to drop over time besides leaks?

Edit: By switching off some parts of my engine, I have confirmed that my game messages system is the cause of the lag:
Collapse JASS:
//  this function is run 50 times per second
function GameMessages takes nothing returns nothing
    local integer i = 0
    local integer j
    local player p
    local string pTable
    local string legPressureBar
    local integer messageAmmount
    local real messageDur

    call ClearTextMessages()

    loop
        set p = Player(i)
        set pTable = GetAttachmentTable(p)
        set messageAmmount = GetTableInt(pTable, "MessageAmmount")
        set j = 0

       //display messages on stack
       loop
            set j = j + 1
            exitwhen j>messageAmmount
            set messageDur = GetTableReal(pTable, "Message"+I2S(j)+"duration")-PhysicsPeriod()
            call SetTableReal(pTable, "Message"+I2S(j)+"duration", messageDur)
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 60.0, GetTableString(pTable, "Message"+I2S(j)+"message"))
            if messageDur<0 then
                call GameMessageRemove(pTable, j, messageAmmount)
                set j = j - 1
                set messageAmmount = messageAmmount-1
            endif            
        endloop

        //display the pressure bar
        if PhysicsIsUnit(GetTableUnit(pTable, "skier")) then
            set legPressureBar = GetTableString(pTable, "legPressureBar")
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 60.0, " ")
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 60.0, "Leg pressure:")
            call DisplayTimedTextToPlayer(p, 0.0, 0.0, 60.0, legPressureBar)
        endif
        set i = i + 1
        exitwhen i>5
    endloop
    set p = null
endfunction

//  support functions
function GameMessageAdd takes player p, string message, real duration returns nothing
    local string pTable = GetAttachmentTable(p)
    local integer messageAmmount = GetTableInt(pTable, "MessageAmmount")
    set messageAmmount = messageAmmount + 1
    call SetTableInt(pTable, "MessageAmmount", messageAmmount)
    call SetTableReal(pTable, "Message"+I2S(messageAmmount)+"duration", duration)
    call SetTableString(pTable, "Message"+I2S(messageAmmount)+"message", message)
endfunction

function GameMessageRemove takes string pTable, integer message, integer messageAmmount returns nothing
    loop
        exitwhen message>messageAmmount
        set message = message + 1
        call SetTableReal(pTable, "Message"+I2S(message-1)+"duration", GetTableReal(pTable, "Message"+I2S(message)+"duration"))
        call SetTableString(pTable, "Message"+I2S(message-1)+"duration", GetTableString(pTable, "Message"+I2S(message)+"message"))
    endloop
    call SetTableInt(pTable, "MessageAmmount", messageAmmount-1)
endfunction

function GameMessageAddAll takes string message, real duration returns nothing
    local integer i = 0
    loop
        call GameMessageAdd(Player(i), message, duration)
        set i = i + 1
        exitwhen i > 6
    endloop
endfunction
07-20-2006, 05:44 PM#2
karukef
Hows it going trying to figure out what makes the lag?

I'd be rather interested to know myself. Slowdowns is the enemy of us all :)

I am sure you will figure it out. Just keep reducing and disabling parts of those functions until you are left with the bare minimals that still causes slowdown.
07-20-2006, 06:24 PM#3
Anitarf
Well, after I figured out as much as I have, I kind of gave up on game messages entirely and decided to just include the data shown by them on the multiboard. I can't say for sure if it's the game message natives or something else in that function that causes bad things to happen, but whatever it is, it has to be run 50*6(number of players)= 300 times per second for two minutes, so that's about 30000 times, to cause this. Even if the game message native is to blame, it won't cause this kind of trouble if used normaly (that is, only on occasion like for player leave messages or hero kills).
07-20-2006, 07:35 PM#4
Vexorian
the game message natives have this effect when used a lot of times.

But well how many messajes at the same time can there be?
07-20-2006, 08:41 PM#5
Anitarf
Mostly, up to 4 max (including the pressure bar).
07-20-2006, 09:06 PM#6
iNfraNe
Quote:
Originally Posted by Vexorian
the game message natives have this effect when used a lot of times.
Have you got any idea to why this happens?
07-20-2006, 09:16 PM#7
Vexorian
blizzard sucks
07-21-2006, 01:10 AM#8
karukef
So the conclusion is, like with quite a few other aspects of War3, that showing a LOT of gamemessages just lags things up?

Well, it's good to know.