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

[GUI] Timer Leaks

Status
Not open for further replies.
Level 12
Joined
Dec 11, 2014
Messages
662
How to stop timers from leaking? I tested my map where I set it so that every 0.01 seconds the timer triggers run and it seems to increase the Memory used quite fast, so does that mean it leaks?
The hive leak tester also reports that the "Create timer" is leaking.
I had this problem for a while now in my map and I am now unsure what is causing it to lag/stutter.
If anyone wants feel free to download it and look into the triggers (Look into my resources). I also found this post here but I didn't get any answers from it
Thanks.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
How would we know how leaks are created?
It is not like:
  • Actions
    • Leak - Create 2 leaks of type Timer[/TRIGGER
  • A leak is that you create something, maybe very useful, without removing it after you are done with it.
  • CreateTimer() doesnt leak, but so does Location() and CreateGroup()
  • Show us YOUR trigger or feel happy with your leaking trigger.
  • Also, 0.01 is not necessary in any case.
  • Using 0.03 is still going to be faster than your eye will reach and is 3 times as efficient as 0.01.
  • 0.04 does get a bit choppy though.
 
Level 12
Joined
Dec 11, 2014
Messages
662
The first trigger (25 second timer)
  • Countdown Timer - Create a timer window for LevelTimer with title First income in ...
  • Set TimerWindVar = (Last created timer window)
  • Countdown Timer - Start LevelTimer as a One-shot timer that will expire in 25.00 seconds
  • Countdown Timer - Show TimerWindVar
  • NxtIncm
    • Events
      • Time - LevelTimer expires
    • Actions
      • Sound - Play Hint <gen>
      • -------- Setup Timer --------
      • Countdown Timer - Destroy TimerWindVar
      • Countdown Timer - Create a timer window for LevelTimer with title Next income in:
      • Set TimerWindVar = (Last created timer window)
      • Countdown Timer - Show TimerWindVar
      • Countdown Timer - Start LevelTimer as a One-shot timer that will expire in Timer_Real seconds
I removed some unimportant stuff. "Timer_Real" is choosable and can be mininum 10 and max 30
 
Level 25
Joined
Sep 26, 2009
Messages
2,384
Is it necessary to destroy the timer? You can just re-use it, can't you?
You cannot destroy timer in GUI, you can only start or pause timer. He's actually destroying timer window.


Well I am changing what the window says, so that's why I destroy it. That might not be needed.
I'll try changing it tomorrow
Why don't you use the following action instead?
  • Countdown Timer - Change the title of *Timer* to *Title*
If you want to check if destroying timers solves the issue, you can use these scripts:
  • Custom script: call DestroyTimer(udg_timer)
  • Custom script: set udg_timer = CreateTimer()
 
Level 12
Joined
Dec 11, 2014
Messages
662
Changed it to this and seems to work.
  • Events
    • Time - LevelTimer expires
  • Actions
    • Countdown Timer - Change the title of (Last created timer window) to Next Income In:
    • Countdown Timer - Start LevelTimer as a One-shot timer that will expire in Timer_Real seconds
Tried setting it so expire every 0.5 seconds and there wasn't a big increase in Memory usage.

@Nichilus Thanks, but I am not sure where to use those custom scripts. The seconds trigger runs after the first 25 second timer expires and then every time the Time_Real timer expires, so every time it starts a new timer
So it still leaks? Because it creates a new one every so often
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,384
@Nichilus Thanks, but I am not sure where to use those custom scripts. The seconds trigger runs after the first 25 second timer expires and then every time the Time_Real timer expires, so every time it starts a new timer
So it still leaks? Because it creates a new one every so often
AFAIK it does not leak. You are re-using the same timer over and over again.
Right now, you create one timer at map initialization and assign that timer into LevelTimer variable. What you are doing in your triggers is starting that same timer over and over again.

I posted those scripts just for you if you wanted to destroy that timer (and create them).
You can also check yourself that the "Start timer" action does not create new timer by destroying the LevelTimer first (via custom script) and then using the "Start LevelTimer" action. It should do nothing since LevelTimer should be null by that time.
 
Level 12
Joined
Dec 11, 2014
Messages
662
You can also check yourself that the "Start timer" action does not create new timer by destroying the LevelTimer first (via custom script) and then using the "Start LevelTimer" action. It should do nothing since LevelTimer should be null by that time.
No custom script is used to create/destroy timers. Also, yes, I tried using custom script to destroy it and saw that it didn't do anything after it was destroyed.
This is what I remade and it seems to work:
  • Countdown Timer - Change the title of (Last created timer window) to Next Income In:
  • Countdown Timer - Start LevelTimer as a Repeating timer that will expire in Timer_Real seconds
So now instead of it expiring and being re-started it repeats on its own and the game still sees that it "Expired" when it reaches 0 so it's working.
But if the timers aren't leaking then what could be? AFAIK everything that is activated throughout the whole game is not leaking, yet the map is lagging.
 
Status
Not open for further replies.
Top