• 🏆 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!

[JASS] Memory issue with jass func

Status
Not open for further replies.
Level 8
Joined
Jul 10, 2008
Messages
353
I suspect this func has a leak cause its the only place TimerGetElapsed is called in the entire war3map.j

JASS:
function Func0001 takes real local_real01 returns nothing 
	local real local_real02
	local real local_real03=TimerGetElapsed(timer009)
	if local_real03<=0 then
		set timer009=CreateTimer()
		call TimerStart(timer009,1000000,false,null)
	endif
	if(local_real01>0)then
		loop
			set local_real02=local_real01-TimerGetElapsed(timer009)+local_real03
			exitwhen local_real02<=0
			if(local_real02>bj_POLLED_WAIT_SKIP_THRESHOLD)then
				call TriggerSleepAction(.1*local_real02)
			else
				call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
			endif
		endloop
	endif
endfunction

From error logs:
Log 1:
Exec:player[number:9]...[Player] OK [9]
Exec:GetTriggerUnit[]...[GetTriggerUnit] OK [1185052('h06Y')]
Exec:GetUnitUserData[unit:1185052('h06Y')]...[GetUnitUserData] OK [5]
Exec:GroupAddUnit...[GroupAddUnit] OK [Group:1049918, unit:1185052('h06Y')]
Exec:GroupRemoveUnit...[GroupRemoveUnit] OK [Group:1049866, unit:1185052('h06Y')]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.25]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2562]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2688]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.275]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:RemoveUnit...[RemoveUnit] OK [unit:1185584('h02D')]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:RemoveUnit...[RemoveUnit] OK [unit:1185218('h087')]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:RemoveUnit...[RemoveUnit] OK [unit:1185814('h04D')]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:RemoveUnit...[RemoveUnit] OK [unit:1185836('h04D')]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:RemoveUnit...[RemoveUnit] OK [unit:1185712('h04D')]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:RemoveUnit...[RemoveUnit] OK [unit:1186906(0)]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2938]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2938]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.3375]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.3438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.3438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.3688]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.375]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.375]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.375]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.3813]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2125]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2188]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.4]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.425]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.4313]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.4313]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.7125]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.475]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.475]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.475]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.4875]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.4938]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.4938]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.5]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6125]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.625]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6313]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6438]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6625]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6688]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.5563]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.6688]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.675]
Exec:TimerGetElapsed[Timer:1052994]...[TimerGetElapsed] OK [4317]
Exec:TriggerSleepAct

Log 2:
Exec:IsPlayerInForce[player:0, Force:1132097]...[IsPlayerInForce] OK [true]
Exec:SetTextTagVisibility...[SetTextTagVisibility] OK [t:99, flag:false]
Exec:RemoveLocation...[RemoveLocation] OK [Location:1132101]
[ForGroup] OK [Group:1131690, callback:574]
Exec:DestroyGroup...[DestroyGroup] OK [Group:1131690]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.5875]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.3125]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.4438]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.525]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.525]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.1]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.2125]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeout:0.25]
Exec:TimerGetElapsed[Timer:1053012]...[TimerGetElapsed] OK [1393]
Exec:TriggerSleepAction...[TriggerSleepAction] OK [timeou

In those 2 logs, these are the last parts of the logger before game crashes. Any suggestions on how I can fix this or if the function posted is "alright" ?
 
Last edited:
Level 8
Joined
Jul 10, 2008
Messages
353
@Chaosy Ye, I know. Forgot to mention am a horrible at jass, but I was hoping that wont be a problem since thats just a tiny bit of code.

Any idea on how I can fix it?
 
Level 8
Joined
Jul 10, 2008
Messages
353
@Chaosy

I got an infinite loop in that function? Or I call that function infinitely somewhere? (I do use that ~50times) as various waits in war3map.j
 
Level 8
Joined
Jul 10, 2008
Messages
353
@Chaosy heh, its the shittiest code ever, I know >.<

But if its "alright". Then I assume one of the times I call that function, ends up in an infinite loop of calling it? Cause the log files is right before the game crash (usually after 1h of game)

How could I write that w/o being shitty? :/
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Have you checked your RAM, i means does it grow more or more ?

Also it's always the same timer handle id from the beginning to the end of the log ?
Because if you mess with the timer009 variable, you could create a new timer when you call your function.

And well, just don't use "local_" and use meaning names, not with numbers, we are humans not some computer.

vJass or an other jass preprocessor could help you, because you could use several times the same name with such keywords as private.
 
Level 8
Joined
Jul 10, 2008
Messages
353
Have you checked your RAM, i means does it grow more or more ?
Yeap starts with like 300kb and grows up to 600kb sometimes even 800kb

Also it's always the same timer handle id from the beginning to the end of the log ?
Because if you mess with the timer009 variable, you could create a new timer when you call your function.
its exactly the same function being called over and over. Do you mean, create a local timer instead of timer009?

vJass or an other jass preprocessor could help you, because you could use several times the same name with such keywords as private.
Any suggestions, am quite bad at vjass and jass but i will battle it out.

What is the purpose of this code?
I use this function like this:
call Func0001(x.x) where x can be any number and it delays the next action in the function by x.x seconds.

Example:
call UnitAddAbility
call func0001(20.)
call UnitRemoveAbility

Adds an ability and after 20seconds it removes it. I pretty much use it anywhere i want to delay the next command. (I use it like 50 times total in the war3map.j)
 
Level 8
Joined
Jul 10, 2008
Messages
353
Well i don't know exactly what's written in the log file, but i suppose there is the handle id of the timer :
Timer:1053012

So is this, this same number at the begin and the end of the log ?
To be perfectly honest am not 100% sure. If you check the log 1, the one above, the timer its 1052994 . So maybe those values change from game to game, am not 100% proficient with this error logger. I suspect in both cases the timer is timer009 cause I only use TimerGetElapsed in the above function.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I think the best way is to just take PolledWait() and fix the handle leak (local handle reference leak).
You can also index them and use one global timer that starts at map init (and can also be used to get the current elapsed gametime) but that is optional.

Naming functions and variables related to what they are supposed to do is good practise.
 
Level 8
Joined
Jul 10, 2008
Messages
353
I mean in the same log file, not in all of them.
Because yeah obviously this number is likely to change for each game.
Ye in same log file the number of the timer is same. Just before the game crash, it spams it.

I dont know what else could be wrong, i attempted to fix memory leaks so many times, but they are still there. Game just crashed again with 800kb (45mins) memory. Before the version that started lagging, game was finishing at about 500kb memory way after 1h.

I think the best way is to just take PolledWait() and fix the handle leak (local handle reference leak).
You can also index them and use one global timer that starts at map init (and can also be used to get the current elapsed gametime) but that is optional.

Naming functions and variables related to what they are supposed to do is good practise.
You mean replace my function with fixed polledwait?
 
Level 8
Joined
Jul 10, 2008
Messages
353
Well this:

JASS:
function FuncTimer01 takes real real01 returns nothing
	
	local timer t
	local real real02
	local real real03=TimerGetElapsed(t)
	if real03<=0 then
		set t=CreateTimer()
		call TimerStart(t,1000000,false,null)
	endif
	if(real01>0)then
		loop
			set real02=real01-TimerGetElapsed(t)+real03
			exitwhen real02<=0
			if(real02>bj_POLLED_WAIT_SKIP_THRESHOLD)then
				call TriggerSleepAction(.1*real02)
			else
				call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
			endif
		endloop
	endif
	set t=null
endfunction

Just rapes the timer >.<
 
Last edited:
Level 8
Joined
Jan 28, 2016
Messages
486
For starters, you don't set the local timer to anything so when you set real03, it has nothing to look up (t = null; real03 is probably set to 0 then). This wouldn't be a problem if you used a global as you did in the original code. Sticking to your new code however, in the conditions of the first If-Then-Else statement, you check if real03<=0 which will most likely be true and t is set to a newly created, non-periodic timer with a 1,000,000 second time-out.

In your second ITE statement, you check to see if real01>0 (most likely is). If so, it starts a loop that in my eyes is infinite; it'll exit once real02<=0 but this will never happen because real03 will be cancelled out by the elapsed time function call. So every time when real02 is set, it's always the same number, therefore never reach 0 and hence an infinite loop. This also applies to your original code.

Explanation
The formula:
real03=TimerGetElapsed(t)
real02=real01-TimerGetElapsed(t)+real03

The problem:
real02=real01-TimerGetElapsed(t)+real03 --->sub real03 for TimerGetElapsed(t)
real02=real01-real03+real03 --->basically, x2=x1-x3+x3
real02=real01-real03+real03 --->the x3s cancel each other out (-x3+x3)
real02=real01 --->end result
 
Level 8
Joined
Jul 10, 2008
Messages
353
This is my interpretation,

JASS:
//1st call and 1st loop
function FuncTimer01 takes real real01 returns nothing 
	local real real02 //lets call this X2
	local real real03=TimerGetElapsed(timer009)
//this is at the first call (start of the game) = 0 lets say this is X3
	if real03<=0 then //since at first call its 0 then
		set timer009=CreateTimer() //creates this
		call TimerStart(timer009,1000000,false,null) //starts this huge timer
	endif
	if(real01>0)then // w/e the number it is, lets call it X1
		loop //1st loop
			set real02=real01-TimerGetElapsed(timer009)+real03
// lets say TimerGetElapsed(timer009) is X4, so first time calling it its X2=X1-X4+X3,
// but X4=X3 so, X2=X1 at first loop
			exitwhen real02<=0
			if(real02>bj_POLLED_WAIT_SKIP_THRESHOLD)then
				call TriggerSleepAction(.1*real02)
			else
				call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
			endif
		endloop
	endif
endfunction

JASS:
//2nd call and 2nd loop
function FuncTimer01 takes real real01 returns nothing 
	local real real02 //lets call this X2
	local real real03=TimerGetElapsed(timer009) // this is no longer = 0
	if real03<=0 then //this is not true anymore
		set timer009=CreateTimer()
		call TimerStart(timer009,1000000,false,null) 
	endif
	if(real01>0)then // w/e the number it is
		loop //2nd+ loop
			set real02=real01-TimerGetElapsed(timer009)+real03
//still X2=X1-X4+X3, X3 is just a stored real, the number is same since the time we 
// entered the function BUT X4 changed, cause time has passed, so now X2=X1-X4+X3 !=X1
			exitwhen real02<=0
			if(real02>bj_POLLED_WAIT_SKIP_THRESHOLD)then
				call TriggerSleepAction(.1*real02)
			else
				call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
			endif
		endloop
	endif
// here i added a bjmsg
endfunction

Need to add I added a bjmsg and the msg spammed during a call instead of being called once. When duration of call was over, msgs also stopped.

Also my 2nd code is total nonsense as pointed out by Dehua_Darbuya, cause there is not a global timer to count total game duration (max game duration is 11.57days, i can live with that :p)

Now, can i re-write this in a way that doesn't crash the game? Or is this even the problem? (When I inserted the faulty 2nd code, the spam stopped (also i had to manually start some timers)

Ye, there is little to improve in the regular PolledWait() function (except the leak ofc).
Except if you can decalculate the accuracy flaw and make it more accurate.

Another (more preferred option) is to use timers instead.
Looping timers? I dont really need that high of accuracy. My aim is rather, I want it easier to make changes on. Which is why the global timer constantly timing the whole game seems easy to work with...

EDIT:
Ok am trying this modification to the initial code
JASS:
function FuncTimer01 takes real real01 returns nothing
	
    local real i=0	
	local real real02
	local real real03=TimerGetElapsed(timer009)
	if real03<=0 then
		set timer009=CreateTimer()
		call TimerStart(timer009,1000000,false,null)
	endif
	if(real01>0)then
		loop
			set real02=real01-TimerGetElapsed(timer009)+real03
			exitwhen real02<=0 or i>(real01/0.1)
			if(real02>bj_POLLED_WAIT_SKIP_THRESHOLD)then
				call TriggerSleepAction(.1*real02)
				set i = real02				
			else
				set i=i+1
				call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
			endif
		endloop
	endif
endfunction
 
Last edited:
Level 8
Joined
Jan 28, 2016
Messages
486
I got it now but I should really stop reading and posting when I'm half asleep. :p

By the way, you might as well take Wietlol's advice and simply remove the leak from the PolledWait function if you're trying to modify it to your needs. Unless you're trying to create a more accurate PolledWait, then by all means carry on.

P.S.: lol, 11.57 days. :p
 
Level 8
Joined
Jul 10, 2008
Messages
353
I got it now but I should really stop reading and posting when I'm half asleep. :p

By the way, you might as well take Wietlol's advice and simply remove the leak from the PolledWait function if you're trying to modify it to your needs. Unless you're trying to create a more accurate PolledWait, then by all means carry on.

P.S.: lol, 11.57 days. :p
I dont think is that hard to create a more accurate "polledwait", just replace TSA with timers and loop it. BUT thats not my aim, my aim is ease of use really, and TSAs +/- 0.26sec inaccuracy is not a problem for my map. And most importantly stop the map from crashing :/
 
Last edited:
Level 8
Joined
Jul 10, 2008
Messages
353
My modification didn't work, in fact I think it made it worst...

Well I don't know what else I can do to fix the map, it keeps crashing in long games :/
 
Status
Not open for further replies.
Top