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

[JASS] Memory Leaks Question

Status
Not open for further replies.
Level 2
Joined
Apr 15, 2012
Messages
18
Hi everyone

I have read "things that leak" by Ralle but there still seems to be leaks... the spawned units goes back to their spawnpoints halfway to their destination when attacked(have set "can flee" to false).

What do you guys suggest I do to fix this?

Thanks

JASS:
function Trig_Lane_1_Actions takes nothing returns nothing
    set udg_TG_Spawn_South_Temp[1] = GetUnitLoc(gg_unit_ewsp_0007)
    set udg_TG_Spawn_South[1] = udg_TG_Spawn_South_Temp[1]
    set udg_TG_Spawn_South_Temp[2] = GetUnitLoc(gg_unit_ewsp_0043)
    set udg_TG_Spawn_South[2] = udg_TG_Spawn_South_Temp[2]
    set udg_Attack_South_Temp[1] = GetUnitLoc(gg_unit_ewsp_0061)
    set udg_Attack_South[1] = PolarProjectionBJ(udg_Attack_South_Temp[1], 100.00, 180.00)
    set udg_Attack_South_Temp[2] = GetUnitLoc(gg_unit_ewsp_0008)
    set udg_Attack_South[2] = PolarProjectionBJ(udg_Attack_South_Temp[2], 100.00, 180.00)
    // Spawn & Move Creeps
    call CreateNUnitsAtLoc( ( udg_NumberOfHeroes * 1 ), ChooseRandomCreepBJ(udg_AvgLevel), Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_TG_Spawn_South[1], bj_UNIT_FACING )
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "attack", udg_Attack_South[1] )
    call CreateNUnitsAtLoc( ( udg_NumberOfHeroes * 1 ), ChooseRandomCreepBJ(udg_AvgLevel), Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_TG_Spawn_South[2], bj_UNIT_FACING )
    call IssuePointOrderLocBJ( GetLastCreatedUnit(), "attack", udg_Attack_South[2] )
    // Resurrect Destructable & Destroy Locations
    call TriggerSleepAction( 0.50 )
    call DestructableRestoreLife( gg_dest_DTlv_0386, 100.00, true )
    call RemoveLocation(udg_TG_Spawn_South_Temp[1])
    call RemoveLocation(udg_TG_Spawn_South_Temp[2])
    call RemoveLocation(udg_TG_Spawn_South[1])
    call RemoveLocation(udg_TG_Spawn_South[2])
    call RemoveLocation(udg_Attack_South_Temp[1])
    call RemoveLocation(udg_Attack_South_Temp[2])
    call RemoveLocation(udg_Attack_South[1])
    call RemoveLocation(udg_Attack_South[2])
endfunction

//===========================================================================
function InitTrig_Lane_1 takes nothing returns nothing
    set gg_trg_Lane_1 = CreateTrigger(  )
    call TriggerRegisterDeathEvent( gg_trg_Lane_1, gg_dest_DTlv_0386 )
    call TriggerAddAction( gg_trg_Lane_1, function Trig_Lane_1_Actions )
endfunction
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1- Remove all the locations and work with X/Y coordenates (GetLocationX or GetUnitX).
2- Use Locals instead of globals
3- Do the PolarProjectionBJ manually to improve trigger functionality
4- Use CreateUnit instead of CreateNUnitsAtLoc (it'll require X/Y)
5- Don't use TriggerSleepAction, use a timer, if you reaaaaaaaaaaally need to.

The reason for them to go back is because, probably, in your gameplay constants you haven't configured the Creep Guard Distance, and Creep Return Distance correctly.
 
this is a GUI converted to JASS, try NOT to do that coz there are many good GUIers here, so they can read it...

anyway your call TriggerSleepAction(0.50) makes them leak coz if your using that location again to another purpose
the last location is gone forever, thus leaks...
but if your restoring life to ONE thing such as 'gg_dest_DTlv_0386' then its OK, still I recommend not to convert your trigger to jass,
it hurts many eyes :)...
 
Level 2
Joined
Apr 15, 2012
Messages
18
Thanks for the suggestions guys :)

Ive increased the creep guard and return distance in the gameplay constants. Seemed to solve my problem (creeps returning when attacked).

mckill2009... Sorry bout that. I had a problem "pasting" my gui "code" in the gui tags in the post. Any suggestions?? I dont want to hurt your eyes again :)
 
Status
Not open for further replies.
Top