• 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.

[General] How does VJASS remove one-time triggers.

Status
Not open for further replies.
Level 12
Joined
Feb 22, 2010
Messages
1,115
Are you talking about triggers which is like runs at map init, or when some time elapsed etc?
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
if you mean GUI "Map Initialization" triggers, it doesnt. If you mean initializer, they are not actually hooked to trigger, but injected into main, which runs when the map loads. function main also calls Init..., which calls the init functions for each separate GUI Trigger, shall there be one of course
 
if you mean GUI "Map Initialization" triggers, it doesnt. If you mean initializer, they are not actually hooked to trigger, but injected into main, which runs when the map loads. function main also calls Init..., which calls the init functions for each separate GUI Trigger, shall there be one of course

So the extra memory that sits there isn't cleaned?


Nobody cares about clearing them much.

They should. The memory limit isn't even 2GB before fatal/crash.
 
Your right however that isn't WC3.

It adds up quickly, and the memory doesn't get reduced unless the process is shut down or restarted. In WC3 there is no such thing as leakless coding, there is only Reduced leaks because there is stuff we don't have access too so it does matter to remove one-time triggers, every little bit helps. Especially considering you can crash even when not at the max memory limit of WC3 due to stuff overwriting its own stuff.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
it is not JassHelper's responsibility to clear "Map Initialization" GUI Triggers. Its the responsibility of the creator of the map.

However code like:

JASS:
struct s
    private static method onInit takes nothing returns nothing
        //code
    endmethod
endstruct

never leaks, because it is not run with trigger, but as I said, inside "main" function, which runs when map loads

Example of compiled code:

JASS:
globals
    // Generated
trigger gg_trg_h= null


//JASSHelper struct globals:
constant integer si__s=1
integer si__s_F=0
integer si__s_I=0
integer array si__s_V

endglobals


//Generated allocator of s
function s__s__allocate takes nothing returns integer
 local integer this=si__s_F
    if (this!=0) then
        set si__s_F=si__s_V[this]
    else
        set si__s_I=si__s_I+1
        set this=si__s_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__s_V[this]=-1
 return this
endfunction

//Generated destructor of s
function s__s_deallocate takes integer this returns nothing
    if this==null then
        return
    elseif (si__s_V[this]!=-1) then
        return
    endif
    set si__s_V[this]=si__s_F
    set si__s_F=this
endfunction

//===========================================================================
// 
// Just another Warcraft III map
// 
//   Warcraft III map script
//   Generated by the Warcraft III World Editor
//   Date: Mon Jul 07 20:33:10 2014
//   Map Author: Unknown
// 
//===========================================================================

//***************************************************************************
//*
//*  Global Variables
//*
//***************************************************************************


function InitGlobals takes nothing returns nothing
endfunction

//***************************************************************************
//*
//*  Triggers
//*
//***************************************************************************

//===========================================================================
// Trigger: h
//===========================================================================
//TESH.scrollpos=0
//TESH.alwaysfold=0
    function s__s_onInit takes nothing returns nothing
        //code
    endfunction
a//===========================================================================
function InitCustomTriggers takes nothing returns nothing
    //Function not found: call InitTrig_h()
endfunction

//***************************************************************************
//*
//*  Players
//*
//***************************************************************************

function InitCustomPlayerSlots takes nothing returns nothing

    // Player 0
    call SetPlayerStartLocation(Player(0), 0)
    call SetPlayerColor(Player(0), ConvertPlayerColor(0))
    call SetPlayerRacePreference(Player(0), RACE_PREF_HUMAN)
    call SetPlayerRaceSelectable(Player(0), true)
    call SetPlayerController(Player(0), MAP_CONTROL_USER)

endfunction

function InitCustomTeams takes nothing returns nothing
    // Force: TRIGSTR_002
    call SetPlayerTeam(Player(0), 0)

endfunction

//***************************************************************************
//*
//*  Main Initialization
//*
//***************************************************************************

//===========================================================================
function main takes nothing returns nothing
    call SetCameraBounds(- 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), - 3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), - 3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM))
    call SetDayNightModels("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl")
    call NewSoundEnvironment("Default")
    call SetAmbientDaySound("LordaeronSummerDay")
    call SetAmbientNightSound("LordaeronSummerNight")
    call SetMapMusic("Music", true, 0)
    call InitBlizzard()

call ExecuteFunc("jasshelper__initstructs44332426")

    call InitGlobals()
    call InitCustomTriggers()

endfunction

//***************************************************************************
//*
//*  Map Configuration
//*
//***************************************************************************

function config takes nothing returns nothing
    call SetMapName("Just another Warcraft III map")
    call SetMapDescription("Nondescript")
    call SetPlayers(1)
    call SetTeams(1)
    call SetGamePlacement(MAP_PLACEMENT_USE_MAP_SETTINGS)

    call DefineStartLocation(0, - 1856.0, 832.0)

    // Player setup
    call InitCustomPlayerSlots()
    call SetPlayerSlotAvailable(Player(0), MAP_CONTROL_USER)
    call InitGenericPlayerSlots()
endfunction




//Struct method generated initializers/callers:

function jasshelper__initstructs44332426 takes nothing returns nothing


    call ExecuteFunc("s__s_onInit")
endfunction

As you see, JassHelper never spawns any trigger to run the initializers
 
Status
Not open for further replies.
Top