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

Leak in TD

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
Of course in TD maps we use a lot of locations. So to solve the leak problem do I have to create a point varriable and set it to the next region centre point and destroy it once the unit is going to that region (or point)

OR

Do I set the variable to the location at initialization (or setup) and always refer to that variable without destroying it each time ?

Example:

  • Initial Moving EA
    • Events
      • Unit - A unit enters SpawnEastAbove <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to BurningLegion
      • ((Entering unit) is A Hero) Equal to False
    • Actions
      • Set AL_PointSingle = (Center of MoveEastAbove01 <gen>)
      • Unit - Order (Entering unit) to Move To AL_PointSingle
      • Custom script: call RemoveLocation(udg_AL_PointSingle)
OR

  • Region Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set AL_PointSingle = (Center of MoveEastHero <gen>)
  • Initial Moving EA Copy
    • Events
      • Unit - A unit enters SpawnEastAbove <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to BurningLegion
      • ((Entering unit) is A Hero) Equal to False
    • Actions
      • Unit - Order (Entering unit) to Move To AL_PointSingle
Does the variable will always refer to the same point ?
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
i think its better if its place in middle of rect, instead of having to make variables and waste memory, but thats just me xD but do u think if you make var then let unit be there it is faster because cp already identifies the point? maybe variable :)

i say second )

If the variable is made at initialization, I think it won't make any difference. Though, I don't know why Centre of Region <gen> won't leak like any point in the region.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Diehard@Azeroth, you make sense.

Middle of rect locations do leak as they make a new location each time you reference them and do not recycle them like boolexprs are. Thus if you refer to the middle of the same rect 1000 times without removing the locations you will have 1000 locations which are all probably considered leaks.

To fix simply make a constant, where by you asign it to a global on map initialization. This is both faster and more efficent in the end as it results in less opperations per execute and is probably faster than X/Y reference as it is only 1 prameter pass. Remember that variables do not slow WC3 down directly as referenced RAM has no overhead from the processor, its stuff which interacts with the engine which does, like handles, objects and strings.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
I made a simple test:
  • UG Check
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UG and do (Actions)
        • Loop - Actions
          • Unit - Remove (Picked unit) from the game
      • Wait 5.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (UG is empty) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: Unit Group Empty
        • Else - Actions
          • Game - Display to (All players) the text: Unit Group NOT Empty
And I got the msg: "Unit Group Empty". Now that confirms it, thanks again for your information.
 
Level 10
Joined
Aug 19, 2008
Messages
491
Do removing a unit from the game that is in a unit group, remove it from that group ?
As far as I know it won't, it will leave a shadow in its place (Captain Griffen's Group Refresh wouldn't make much sence otherwise), though the unit won't be counted.
It's like the local reference count bug Blizzard didn't fix...

I'm not too sure about this, so don't take these words for granted.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Do removing a unit from the game that is in a unit group, remove it from that group ?
No, it does not. This is a major bad leak in WC3. Although the unit is removed from the game it still counts as being in the group, as the first unit of the group or enuming through it shows. This blocks up valuable hash indexes in the group object slowing it down. After like 200 leaks this way opperations involving adding or removing units in the group (not looping through as that uses O(1) efficency per unit) start to take 1/10 of a second and more resulting in the game locking up when ever it is used.

To fix this you have to remove the unit from the group before removing the unit from the game or clear the group when it is empty. Equally you can order it to enum all units, clear the group and if the unit is alive add it back to the group to remove all the leaks (this is the most effective way for preserving the contense of the group). This is not limated to units being removed via triggers, it also occurs when units are removed on death and is only a problem when using groups which have to hold units for a elongated period of time.

This information is sourced from WC3C and comes from the very respectable captain griffen and one of the admins there. Thus I would believe it over some random people here saying its not a problem.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Do this fix the problem ?

  • Selling Structures
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Sell Structure (Easy)
          • (Ability being cast) Equal to Sell Structure (Normal)
          • (Ability being cast) Equal to Sell Structure (Hard)
    • Actions
      • Unit Group - Add (Casting unit) to SelledStructures
      • Set TempLoc = (Position of (Casting unit))
      • Player - Add (Integer(((Real((Point-value of (Casting unit)))) x SellFactor))) to (Owner of (Casting unit)) Current gold
      • Special Effect - Create a special effect at TempLoc using UI\Feedback\GoldCredit\GoldCredit.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Wait 1.00 game-time seconds
      • Unit Group - Pick every unit in SelledStructures and do (Actions)
        • Loop - Actions
          • Set TempLoc = (Position of (Picked unit))
          • Special Effect - Create a special effect at TempLoc using Objects\Spawnmodels\NightElf\NEDeathMedium\NEDeath.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_TempLoc)
          • Unit Group - Remove (Picked unit) from SelledStructures
          • Unit - Remove (Picked unit) from the game
 
Status
Not open for further replies.
Top