HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Simple script runs game into ground

02-01-2010, 03:26 AM#1
Windexglow
SELF ANSWERED - see bottom of post

The purpose of this is to check how many units I can make, items, than what happens to performance if I clean them off and so on. Just a small experiment for bigger things.

The problem is after 10 seconds my framerate suddenly begins to dip until the game crashes after reaches <5fps. Is something leaking I don't know about?

Right now all it does is show the debug info. It doesn't do anything else yet framerate will still go down. Removing the /* */ tags doesn't seem to effect performance.

Starts hitting at around 1.3k runs, with it normally crashing at around 3k.
Uses vjass

You can test the script just by making a new map. Be sure to test work, since some computers don't handle app crashes too well.
Collapse JASS:
globals
    real units_made = 0
    real units_deleted = 0
    
    real items_made = 0
    real items_deleted = 0
    
    real total_exist = 0
    real total_made = 0
    
    real total_runs = 0
endglobals
function Trig_loop_Actions takes nothing returns nothing
    local unit u = null
    local item i = null
    call ClearTextMessages()
    call BJDebugMsg("units_made="+R2S(units_made))
    call BJDebugMsg("units_deleted="+R2S(units_deleted))
        call BJDebugMsg("---------------------------")
    call BJDebugMsg("items_made="+R2S(items_made))
    call BJDebugMsg("items_deleted="+R2S(items_deleted))
        call BJDebugMsg("---------------------------")
    call BJDebugMsg("total_exist="+R2S(total_exist))
    call BJDebugMsg("total_made="+R2S(total_made))
    call BJDebugMsg("total_runs="+R2S(total_runs))
    if total_runs >= 2500 then
        call BJDebugMsg("Limit")
        return
    endif
    /*
    
        set u = CreateUnit(Player(13), 'hpea', 0, 0, 0)
        set units_made = units_made + 1
        set total_made = total_made + 1
        set total_exist = total_exist + 1
      
      set i = CreateItem('afac', 0, 0)
      set items_made = items_made + 1
      set total_made = total_made + 1
      set total_exist = total_exist + 1
        
    
    
    if i != null then
        call RemoveItem(i)
            set items_deleted = items_deleted + 1
            set total_exist = total_exist - 1
    endif
    
    if u != null then
        call RemoveUnit(u)
            set units_deleted = units_deleted + 1
            set total_exist = total_exist - 1
    endif
    set u = null
    set i = null
    */
    set total_runs = total_runs + 1
    
endfunction

//===========================================================================
function InitTrig_loop takes nothing returns nothing
    set gg_trg_loop = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_loop, 0.01 )
    call TriggerAddAction( gg_trg_loop, function Trig_loop_Actions )
endfunction



EDIT: Do not answer to this topic. Turns out the script simply runs too quickly for wc3.
call TriggerRegisterTimerEventPeriodic( gg_trg_loop, 0.03 ) doesn't cause it to lag.
Sorry!
02-01-2010, 06:21 AM#2
grim001
You print a lot of strings there. One thing that can quickly cause the game to lag is creating and printing tons of strings. Most likely, it will still lag at 0.03 seconds period, it'll just take 3x longer to reach the point where it begins to lag.
02-01-2010, 12:59 PM#3
Anitarf
grim001 is right, the problem is in your debug messages. You were displaying 900 messages per second, which is about six times more than what I did in one of my maps once. That map would become unplayable after about one minute. Game messages are just bugged like that, use less of them (like, only once every second, for example) and you should be fine.