• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Leak Test

Level 37
Joined
Mar 6, 2006
Messages
9,240
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