• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Need help making this Leak Proof

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
  • Sense Effect P1
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set UnitsOnMap = (Units in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) has buff Sense ) Equal to True
        • Then - Actions
        • Else - Actions
          • Unit Group - Pick every unit in UnitsOnMap and do (Actions)
            • Loop - Actions
              • Set UnitPositionP1 = (Position of (Picked unit))
              • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
              • Unit - Kill (Last created unit)
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
Driving me bonkers. Can't even test the spell until this is leak proof, it causes that much lag. Lol
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
  • Sense Effect P1
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set UnitsOnMap = (Units in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) has buff Sense ) Equal to True
        • Then - Actions
        • Else - Actions
          • Unit Group - Pick every unit in UnitsOnMap and do (Actions)
            • Loop - Actions
              • Set UnitPositionP1 = (Position of (Picked unit))
              • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
              • Unit - Kill (Last created unit)
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
Driving me bonkers. Can't even test the spell until this is leak proof, it causes that much lag. Lol

Why do you think its leaks what causes the lag? You are enumerating over all units on the entire map. And this 100 times per second...

Oh and you are refering to "Picked Unit" outside of a pick loop. Whats the idea behind that?
 
Level 12
Joined
May 20, 2009
Messages
822
Why do you think its leaks what causes the lag? You are enumerating over all units on the entire map. And this 100 times per second...

Oh and you are refering to "Picked Unit" outside of a pick loop. Whats the idea behind that?

I'm a moron that don't know anything, that's what.

Fixed the arrangement, now this should make better sense.

  • Sense Effect P1
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set UnitsOnMap = (Units in (Playable map area))
      • Unit Group - Pick every unit in UnitsOnMap and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Sense ) Equal to False
            • Then - Actions
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
            • Else - Actions
              • Set UnitPositionP1 = (Position of (Picked unit))
              • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
              • Set CreatedUnit = (Last created unit)
              • Unit - Kill CreatedUnit
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
Basically, now I just need to destroy the CreatedUnit variable, but I'm a total noob to this stuff so I don't know the thing for it.

At least, I think this should now be leak-proof right?
 
Level 11
Joined
Nov 15, 2007
Messages
781
It doesn't lag because of leaks, it lags because it's performing way too many functions 100 times per second. Change the interval to every .05, or even every .1.
 
Level 12
Joined
May 20, 2009
Messages
822
It doesn't lag because of leaks, it lags because it's performing way too many functions 100 times per second. Change the interval to every .05, or even every .1.

This variable right here

  • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
  • Set CreatedUnit = (Last created unit)
  • Unit - Kill CreatedUnit
Is what's leaking. And I don't know how to destroy it. Do I use DestroyGroup ()? Do I Use RemoveUnit ()? Do I use KillUnit ()? I don't know.

I can tell that it's leaking because my game entirely locks up and becomes 100% unresponsive. If it was just lagging because of how quickly the trigger was going, it wouldn't lock my game up. Right?

It's probably not that great of a reputable program, I don't really know, but Leak Checker v3 says :

Variables
UnitsOnMap : (Line: 6) Unit Group - Removed: Yes
UnitPositionP1 : (Line: 16) Location - Removed: Yes
CreatedUnit : (Line: 18) Unit Group - Removed: No

Summary
Total Leaks: 0
Unremoved Variables: 1
Scan duration: 0 seconds
Total Lines Scanned: 23
Total Words Scanned: 127

It says CreatedUnit is a unit group, but when I try call DestroyGroup(CreatedUnit) the WC3 Editor gives me an error.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
The problem is not the leak. Its just a lag because you are executing stuff too frequently.
If it was just lagging because of how quickly the trigger was going, it wouldn't lock my game up. Right?
Thats not correct. Both kinds of lags can "lock up" your game.

The thing about leaks is: if you have leaks that are caused by periodical stuff then your laggs are getting worse the longer the game runs. This means in the beginning of the game it should be fine and after some time the lagging should start.
Now its hard to tell "when" the lag starts, but typically it takes several minutes (unless you have really really crazy leaks, but then your map should crash anyway).
 
Level 12
Joined
May 20, 2009
Messages
822
The problem is not the leak. Its just a lag because you are executing stuff too frequently.

Thats not correct. Both kinds of lags can "lock up" your game.

The thing about leaks is: if you have leaks that are caused by periodical stuff then your laggs are getting worse the longer the game runs. This means in the beginning of the game it should be fine and after some time the lagging should start.
Now its hard to tell "when" the lag starts, but typically it takes several minutes (unless you have really really crazy leaks, but then your map should crash anyway).

Alright, thanks. I tried changing it to .1 and it worked...xD


EDIT:

Okay, after a few moments it begins to stack up lag. Should I just make it a second or something?

Here's all the code

  • Sense Effect P1
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set UnitsOnMap = (Units in (Playable map area))
      • Unit Group - Pick every unit in UnitsOnMap and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Sense ) Equal to False
            • Then - Actions
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
              • Custom script: call DestroyGroup(udg_CreatedUnit)
            • Else - Actions
              • Set UnitPositionP1 = (Position of (Picked unit))
              • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
              • Set CreatedUnit = (Last created unit group)
              • Unit - Kill (Random unit from CreatedUnit)
              • Custom script: call DestroyGroup(udg_UnitsOnMap)
              • Custom script: call DestroyGroup(udg_CreatedUnit)
              • Custom script: call RemoveLocation(udg_UnitPositionP1)
 
Last edited:
Your first issue: Working with 'PickEveryUnit and do Actions' is a very heavy operation GUI.
So with 0.01 it's too expensive, and it will cause lags. Exactly same actions with 0.01 but with loop and index won't cause lags.

And to your post above:
I think it's not needed to pick every single unit in whole map. This means a lot of useless actions, which just are expensive.
Once unit get this buff, you could add the unit to UnitGroup, and then only pick units in this UnitGroup to check if unit has still buff or not.

Your complete 'Then - Actions' block is useless.

In 'Else - Actions', you dont create any unitgroup, only a dummy unit. So no need need to set/work/remove this group at the moment.

Maybe you want something like this: Add unit to UnitGroup_2
After the PickEveryUnit - action block you do kill random unit from Unitgroup_2.
 
Last edited:
Level 11
Joined
Nov 15, 2007
Messages
781
Disable actions one by one until the lag stops and you'll have your answer on what is causing it.

I suspect it might be

  • Unit - Create 1 Dummy Sense Unit for ArcherSightP1 at UnitPositionP1 facing UnitPositionP1
  • Set CreatedUnit = (Last created unit group)
  • Unit - Kill (Random unit from CreatedUnit)
I've never seen anyone deal with clearing dummy units like this, it makes no logical sense to me (you could just do Kill (Last created unit)). I'm not even sure if "Last created unit group" works when you create a single unit, which could mean it's creating a bunch of dummy units who stay on the map permanently (which would eventually cause a great amount of lag, I imagine).

This definitely wouldn't be lagging on its own at a mere 100 millisecond interval, and the fact that the lag is no longer locking you up instantly but instead building up over time does indicate a leak.

P.S. the method I posted for this ability in your other thread wouldn't have this problem and would be much less resource-intensive to run in general :crazz:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
You create a dummy unit under every unit on the map. This is probably very expensive as each dummy unit may need to be displaced (which is costly in WC3) resulting in a huge consumption of processor time. On top of that you do this more than once a frame, total madness!

Try recycling dummy units. If you need to create dummies, make them nearby the unit semi-randomly so that they have little chance of needing displacement. You could also try load spreading so that each update only does some units.

Thus my advice.
1. Lower update frequency.
2. Load spread over many updates (can raise update frequency for this to some extent).
3. Recycle dummy units. Create them once and only remove them when the effect ends.
4. Cache intermediate results. Use a pre-filtered group of units containing the buff and remove / add them only when the buff status changes.
5. Remove dummy unit, not kill as kill may require time for removal.

What does this dummy do anyway that it needs to be created and killed 100 times a second? Maybe move it instead?
 
Level 11
Joined
Nov 15, 2007
Messages
781
You create a dummy unit under every unit on the map. This is probably very expensive as each dummy unit may need to be displaced (which is costly in WC3) resulting in a huge consumption of processor time. On top of that you do this more than once a frame, total madness!

Try recycling dummy units. If you need to create dummies, make them nearby the unit semi-randomly so that they have little chance of needing displacement. You could also try load spreading so that each update only does some units.

Thus my advice.
1. Lower update frequency.
2. Load spread over many updates (can raise update frequency for this to some extent).
3. Recycle dummy units. Create them once and only remove them when the effect ends.
4. Cache intermediate results. Use a pre-filtered group of units containing the buff and remove / add them only when the buff status changes.
5. Remove dummy unit, not kill as kill may require time for removal.

What does this dummy do anyway that it needs to be created and killed 100 times a second? Maybe move it instead?

He changed the interval to .1

I think you've got it spot on with "Remove, don't kill" though. If the lag is now taking a while to set in after changing the interval, it's probably because a bunch of units are piling up, dead though they may be.
 
Status
Not open for further replies.
Top