• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Leak Test

Level 37
Joined
Mar 6, 2006
Messages
9,243
JASS:
library leakTest initializer onInit
    globals
        private timer t = CreateTimer()
        private constant integer LOCS = 500
        private integer c = 0
    endglobals

    private function leaks takes nothing returns nothing
        local integer i = LOCS
        
        loop
            exitwhen i == 0
            set udg_loc = Location(0,0)
            call RemoveLocation(udg_loc)
            set c = c + 1
            set i = i - 1
        endloop
        //set udg_loc = null
    endfunction
    
    private function pauseResume takes nothing returns nothing
        if ModuloInteger(GetTriggerExecCount(GetTriggeringTrigger()) , 2) == 1 then
            call BJDebugMsg("started")
            call TimerStart(t, 0.01, true, function leaks)
        else
            call BJDebugMsg("paused, " + "locs created: " + I2S(c))
            call PauseTimer(t)
        endif
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterPlayerEvent(t, Player(0), EVENT_PLAYER_END_CINEMATIC)
        call TriggerAddAction(t, function pauseResume)
    endfunction
endlibrary
Top