- Joined
- Dec 12, 2012
- Messages
- 1,007
Hello again,
my function I am sitting on since a few days is finally doing what I want, but it causes heavy memory leaks. I really dont understand why, I tried to make everything local and destroy it afterwards, but still it leaks my memory completley within minutes. Here is the code:
The function basically displays a variable (counter) as a floatingtext over a unit. If the Unit gets invisible the text changes its color and gets invisible to the enemy player etc.
I really can't figure out where the memory leak comes from, but it has to be in this trigger, as it disappears if I deactivate it...
my function I am sitting on since a few days is finally doing what I want, but it causes heavy memory leaks. I really dont understand why, I tried to make everything local and destroy it afterwards, but still it leaks my memory completley within minutes. Here is the code:
JASS:
function Trig_text_Actions takes nothing returns nothing
local location myLoc = GetUnitLoc(gg_unit_Obla_0006)
local texttag myText = null
local string myString = null
local force AllPlayers = GetPlayersAll()
local player Player_0 = Player(0)
local player Player_1 = Player(1)
local player Player_11 = Player(11)
if ( udg_counter < 7) then
set myString = I2S(udg_counter)
else
set myString = "test"
endif
if udg_destroyedText == 0 then
call DestroyTextTagBJ( myText )
set udg_destroyedText = 1
endif
if (IsUnitDeadBJ(gg_unit_Obla_0006) == false) and ( not ( gg_unit_Obla_0006 == null ) ) and ( ( GetUnitAbilityLevelSwapped('A001', gg_unit_Obla_0006) >= 1 ) or ( GetUnitAbilityLevelSwapped('A000', gg_unit_Obla_0006) >= 1 ) ) then
set udg_destroyedText = 0
if ( udg_counter < 7) then
if (IsUnitVisible(gg_unit_Obla_0006, Player_11) == true) then
set myText = CreateTextTagLocBJ( myString, myLoc, 200, 12, 100, 0, 0, 0)
call ShowTextTagForceBJ( true, myText, AllPlayers )
else
if GetLocalPlayer() == Player_0 then
set myText = CreateTextTagLocBJ( myString, myLoc, 200, 12, 100, 35, 30, 0)
call ShowTextTagForceBJ( true, myText, GetForceOfPlayer(Player_0) )
else
if (IsUnitVisible(gg_unit_Obla_0006, Player_1) == true) then
set myText = CreateTextTagLocBJ( myString, myLoc, 200, 12, 100, 35, 30, 0)
call ShowTextTagForceBJ( true, myText, AllPlayers )
endif
endif
endif
else
if (IsUnitVisible(gg_unit_Obla_0006, Player_11) == true) then
set myText = CreateTextTagLocBJ( myString, myLoc, 200, 12, 100, 0, 0, 0 )
call ShowTextTagForceBJ( true, myText, AllPlayers )
else
if GetLocalPlayer() == Player_0 then
set myText = CreateTextTagLocBJ( myString, myLoc, 200, 12, 100, 35, 30, 0 )
call ShowTextTagForceBJ( true, myText, GetForceOfPlayer(Player_0) )
else
if (IsUnitVisible(gg_unit_Obla_0006, Player_1) == true) then
set myText = CreateTextTagLocBJ( myString, myLoc, 200, 12, 100, 35, 30, 0)
call ShowTextTagForceBJ( true, myText, AllPlayers )
endif
endif
endif
endif
endif
call RemoveLocation(myLoc)
call DestroyForce(AllPlayers)
set AllPlayers = null
set Player_0 = null
set Player_1 = null
set Player_11 = null
set myText = null
set myLoc = null
set myString = null
endfunction
//===========================================================================
function InitTrig_text takes nothing returns nothing
set gg_trg_text = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_text, 0.00 )
call TriggerAddAction( gg_trg_text, function Trig_text_Actions )
endfunction
The function basically displays a variable (counter) as a floatingtext over a unit. If the Unit gets invisible the text changes its color and gets invisible to the enemy player etc.
I really can't figure out where the memory leak comes from, but it has to be in this trigger, as it disappears if I deactivate it...