1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[GUI] Timer Leaks

Discussion in 'World Editor Help Zone' started by DaneTheBeast, May 14, 2016.

  1. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    580
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.
     
  2. neo_sluf

    neo_sluf

    Joined:
    Feb 5, 2012
    Messages:
    1,432
    Resources:
    5
    Maps:
    5
    Resources:
    5
    0.01 is so brutal. Your not allowing the the Pause Time to run.


    Try on 5 sec or just use DynamicIndexing.

    As far as I know I havent saw a Custom Script for destroying timers. Lets wait for JASS Wizz.
     
  3. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,501
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    Stop using hive's leak tester. It's inaccurate.

    To get back on topic, a timer won't leak if they are global. You only ever create the timer once, and that is on map init. Dr Super Good already answered your question in the thread.
     
  4. neo_sluf

    neo_sluf

    Joined:
    Feb 5, 2012
    Messages:
    1,432
    Resources:
    5
    Maps:
    5
    Resources:
    5
    Ah so thats why you only have PAUSE TIMER.

    But is creating timer constantly cause lag, right?
     
  5. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,501
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    From what I understand, creating a timer itself doesn't have any issues. However, having a lot of timers running at once will cause a noticeable FPS drop.
     
  6. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,641
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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.
     
  7. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    580
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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
     
  8. Rheiko

    Rheiko

    Joined:
    Aug 27, 2013
    Messages:
    2,936
    Resources:
    7
    Icons:
    2
    Spells:
    3
    Tutorials:
    2
    Resources:
    7
    Is it necessary to destroy the timer? You can just re-use it, can't you?
     
  9. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    580
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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
     
  10. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    You cannot destroy timer in GUI, you can only start or pause timer. He's actually destroying timer window.


    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()
     
  11. Rheiko

    Rheiko

    Joined:
    Aug 27, 2013
    Messages:
    2,936
    Resources:
    7
    Icons:
    2
    Spells:
    3
    Tutorials:
    2
    Resources:
    7
    That's what I meant, He could just change the title of the timer window using the action you've just mentioned but he didn't. He destroyed and made a new timer window instead. That's why I asked.
     
  12. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    580
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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: May 15, 2016
  13. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    1,968
    Resources:
    0
    Resources:
    0
    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.
     
  14. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    580
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.