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. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Choose your ride to damnation in the 5th Special Effect Contest Poll.
    Dismiss Notice
  5. The winners of the 13th Techtree Contest have been announced!
    Dismiss Notice
  6. The 13th Music Contest Poll is up! Vote for the best tracks in this symphony of frost and flame.
    Dismiss Notice
  7. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  8. 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.

Do loops leak like shit?

Discussion in 'Triggers & Scripts' started by Megafyr, Apr 1, 2009.

  1. Megafyr

    Megafyr

    Joined:
    Oct 29, 2007
    Messages:
    957
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Need help with my superoverleakage triggering!

    Uhm.. Yah.. I had some triggers, that where running at every 0.04 second of time for a player. And then I thought it was a nice idea to make loop actions, so that the triggers work for all players. And uhm.. Now I got a nice moderate framerate drop while playing from about 60 (which I constantly had before I used teh loops) to I think 0. (but while playing I only tested untill the framerate hit 20.)

    I can't seem to find the leaks, cause there must be some huge shit leaking. Can anybody help me? I'll post an example of a trigger here. They all follow the same pattern.
     
    Last edited: Apr 1, 2009
  2. BearMachine

    BearMachine

    Joined:
    Mar 11, 2009
    Messages:
    24
    Resources:
    0
    Resources:
    0
    Post the trigger and i might be able to help.
     
  3. Megafyr

    Megafyr

    Joined:
    Oct 29, 2007
    Messages:
    957
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    • Grass
      • Events
        • Time - Every 0.05 seconds of game time
      • Conditions
      • Actions
        • For each (Integer tmp_integer) from 1 to 4, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • detect_up[tmp_integer] Equal to 1
              • Then - Actions
                • Set tmp_loc2 = (Position of Player[tmp_integer])
                • Set tmp_loc = (tmp_loc2 offset by 800.00 towards (Facing of Player[tmp_integer]) degrees)
                • Custom script: call RemoveLocation(udg_tmp_loc2)
              • Else - Actions
                • Set tmp_loc = (Position of Player[tmp_integer])
            • Set tmp_group = (Units in (Region centered at tmp_loc with size (2000.00, 2000.00)) matching ((Unit-type of (Matching unit)) Equal to Grass))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in tmp_group) Less than 32
              • Then - Actions
                • Set tmp_loc2 = (Random point in (Region centered at tmp_loc with size (1000.00, 1000.00)))
                • Unit - Create 1 Grass for Player 5 (Yellow) at (Random point in (Region centered at tmp_loc2 with size (1000.00, 1000.00))) facing Default building facing degrees
                • Custom script: call RemoveLocation(udg_tmp_loc2)
                • Set tmp_real = (Random real number between 80.00 and 150.00)
                • Animation - Change (Last created unit)'s size to (tmp_real%, tmp_real%, tmp_real%) of its original size
              • Else - Actions
                • Do nothing
            • Custom script: call RemoveLocation(udg_tmp_loc)
            • Custom script: call DestroyGroup(udg_tmp_group)


    Most of the triggers are like this.
     
  4. EpixBelongToMe

    EpixBelongToMe

    Joined:
    Aug 19, 2006
    Messages:
    188
    Resources:
    1
    Maps:
    1
    Resources:
    1
    hmmm you leak 2 regions every time. maybe try to use the point with offset function.
    and remove the "Do Nothing" because the gui "Do Nothing" does not do nothing! It always calls another function and that one does nothing. so just remove it.
     
  5. Megafyr

    Megafyr

    Joined:
    Oct 29, 2007
    Messages:
    957
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Huh? I do.. damn.. Can you please point them out, I'm blind to them. : (
     
  6. EpixBelongToMe

    EpixBelongToMe

    Joined:
    Aug 19, 2006
    Messages:
    188
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Set tmp_group = (Units in ("!>>>Region centered at tmp_loc<<<!" with size (2000.00, 2000.00)) matching ((Unit-type of (Matching unit)) Equal to Grass))


    Set tmp_loc2 = (Random point in ("!>>>Region centered at tmp_loc<<<!" with size (1000.00, 1000.00)))


    Unit - Create 1 Grass for Player 5 (Yellow) at (Random point in ("!>>>Region centered at tmp_loc2<<<!" with size (1000.00, 1000.00))) facing Default building facing degrees


    ok you leak even 3 regions
     
  7. Megafyr

    Megafyr

    Joined:
    Oct 29, 2007
    Messages:
    957
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Okay, I might sound very noobish for asking, but I'm gonna risk it.. How do I fix them? : | Seriously I had no idea those were leaking.
     
  8. EpixBelongToMe

    EpixBelongToMe

    Joined:
    Aug 19, 2006
    Messages:
    188
    Resources:
    1
    Maps:
    1
    Resources:
    1
    it can be done with jass but i'm not very experienced in jass. maybe someone else with jass knowledge can help or you try to use the "point with offset function" don't know if it works for your needs
     
  9. Megafyr

    Megafyr

    Joined:
    Oct 29, 2007
    Messages:
    957
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Damn.. Point with offset wont do it. Well, anyway, thanks for taking time to help. : ) +rep
     
  10. Illidan(Evil)X

    Illidan(Evil)X

    Joined:
    Oct 24, 2004
    Messages:
    646
    Resources:
    150
    Models:
    109
    Icons:
    27
    Skins:
    2
    Maps:
    12
    Resources:
    150
    This should work. You will need a new region variable called 'tmp_region'.
    tmp_real is used to set the region size.

    • Grass
      • Events
        • Time - Every 0.05 seconds of game time
      • Conditions
      • Actions
        • Custom script: set udg_tmp_region = Rect ( 0, 0, 0, 0 )
        • For each (Integer tmp_integer) from 1 to 4, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • detect_up[tmp_integer] Equal to 1
              • Then - Actions
                • Set tmp_loc2 = (Position of Player[tmp_integer])
                • Set tmp_loc = (tmp_loc2 offset by 800.00 towards (Facing of Player[tmp_integer]) degrees)
                • Custom script: call RemoveLocation ( udg_tmp_loc2 )
              • Else - Actions
                • Set tmp_loc = (Position of Player[tmp_integer])
            • Set tmp_real = 2000.00
            • Custom script: call SetRect ( udg_tmp_region, GetLocationX(udg_tmp_loc) - (udg_tmp_real * 0.5), GetLocationY(udg_tmp_loc) - (udg_tmp_real * 0.5), GetLocationX(udg_tmp_loc) + (udg_tmp_real * 0.5), GetLocationY(udg_tmp_loc) + (udg_tmp_real * 0.5) )
            • Set tmp_group = (Units in tmp_region matching ((Unit-type of (Matching unit)) Equal to Grass))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in tmp_group) Less than 32
              • Then - Actions
                • Set tmp_real = 2000.00
                • Custom script: call SetRect ( udg_tmp_region, GetLocationX(udg_tmp_loc) - (udg_tmp_real * 0.5), GetLocationY(udg_tmp_loc) - (udg_tmp_real * 0.5), GetLocationX(udg_tmp_loc) + (udg_tmp_real * 0.5), GetLocationY(udg_tmp_loc) + (udg_tmp_real * 0.5) )
                • Set tmp_loc2 = (Random point in tmp_region)
                • Unit - Create 1 Grass for Player 5 (Yellow) at tmp_loc2 facing Default building facing degrees
                • Custom script: call RemoveLocation(udg_tmp_loc2)
                • Set tmp_real = (Random real number between 80.00 and 150.00)
                • Animation - Change (Last created unit)'s size to (tmp_real%, tmp_real%, tmp_real%) of its original size
              • Else - Actions
            • Custom script: call RemoveLocation ( udg_tmp_loc )
            • Custom script: call DestroyGroup ( udg_tmp_group )
        • Custom script: call RemoveRect ( udg_tmp_region )
     
  11. peq

    peq

    Joined:
    May 13, 2007
    Messages:
    171
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Besides the leaks there are some other hidden performance killers in your code.

    a) picking units takes more time than most other actions. Avoid it when possible. If there are many other units beside grass in the rect try to run this the other way round by picking all units of a type and then check if they are in the region.
    b) (Number of units in tmp_group) sounds harmless but everytime you run this function it will run a loop over all the units in that group.
     
  12. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,843
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Loops don't leak, you do.
     
  13. Rmx

    Rmx

    Joined:
    Aug 27, 2007
    Messages:
    1,088
    Resources:
    18
    Icons:
    3
    Spells:
    15
    Resources:
    18
    Good one GhostWolf, but don't be tuff at that guy, he didn't do anything bad to u.

    If u are having problems in Illidian... solution just give me a PM and i'll help ;).