• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Memory Leak psuedo projectile system

Status
Not open for further replies.
Level 2
Joined
Apr 24, 2005
Messages
20
So I've been working on this system for a bit, using ever more increasing amounts of custom scripts in a gradual transition to use more JASS. Anyway, after monitoring the war3.exe's memory usage whilst executing this function, the memory seems to go up and never back down. Now I think there are two possible causes for this, either due to the inherent leaking of memory that is caused by creating/destroying units (I fully intend to recycle dummy units at some point), or perhaps I'm missing an obvious leak or maybe it's a boolexpr leak, I'm not too sure. Any information I've found on boolexpr leaks has been kind of vague and ambiguous, so I'm not sure of the exact nature of the leak, only that there is one. I was hoping if you guys could give this a look and tell me if you've spotted any leaks I've glanced over or affirm my suspicions.

  • ProjectileMotion
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • (Number of units in ProjectileGroup) Greater than 0
    • Actions
      • Unit Group - Pick every unit in ProjectileGroup and do (Actions)
        • Loop - Actions
          • -------- We remove locust so that we can manipulate the projectile --------
          • Unit - Hide ProjectileDummy
          • Unit - Unhide ProjectileDummy
          • -------- Hiding and Unhiding Removes Locust --------
          • Set ProjectileLife = (Load 0 of (Key (Picked unit)) from ProjectileTable)
          • Set ProjectileDummy = (Picked unit)
          • Set ProjectileID = (Key (Picked unit))
          • Set ProjectileSize = (Load 3 of (Key (Picked unit)) from ProjectileTable)
          • Set ProjectileLife = (ProjectileLife - 0.03)
          • Hashtable - Save ProjectileLife as 0 of (Key (Picked unit)) in ProjectileTable
          • Set ProjectileLocationOffset = ((Position of ProjectileDummy) offset by (Load 1 of ProjectileID from ProjectileTable) towards (Load 2 of ProjectileID from ProjectileTable) degrees)
          • Set ProjectileLocation = (Position of ProjectileDummy)
          • Set ProjectileGroupLoc = ((Position of ProjectileDummy) offset by (Load 1 of ProjectileID from ProjectileTable) towards (Load 2 of ProjectileID from ProjectileTable) degrees)
          • Set ProjectileTempGroup = (Units within (Load 3 of ProjectileID from ProjectileTable) of ProjectileGroupLoc)
          • Unit Group - Pick every unit in ProjectileTempGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ProjectileLife Equal to 0.00
                      • And - All (Conditions) are true
                        • Conditions
                          • (Number of units in ProjectileTempGroup) Greater than 0
                          • ProjectileSize Greater than or equal to 0.00
                          • (Distance between (Position of (Picked unit)) and (Position of ProjectileDummy)) Less than or equal to ProjectileSize
                          • ((Picked unit) is alive) Equal to True
                          • (Owner of (Picked unit)) Not equal to (Owner of ProjectileDummy)
                • Then - Actions
                  • -------- If the projectiles life time is up, or it collide with a unit, kill it and then remove it --------
                  • Unit Group - Remove ProjectileDummy from ProjectileGroup
                  • Unit - Kill ProjectileDummy
                  • Unit - Remove ProjectileDummy from the game
                  • Hashtable - Clear all child hashtables of child ProjectileID in ProjectileTable
                  • Custom script: call RemoveUnit(udg_ProjectileDummy)
                  • Custom script: call RemoveLocation(udg_ProjectileGroupLoc)
                  • Custom script: call DestroyGroup (udg_ProjectileTempGroup)
                • Else - Actions
                  • Set ProjectileLocationOffset = ((Position of ProjectileDummy) offset by (Load 1 of ProjectileID from ProjectileTable) towards (Load 2 of ProjectileID from ProjectileTable) degrees)
                  • Set ProjectileCoords[0] = (X of ProjectileLocationOffset)
                  • Set ProjectileCoords[1] = (Y of ProjectileLocationOffset)
                  • -------- IF THE TERRAIN ISNT PATHABLE STOP THE PROJECTILE --------
                  • Custom script: if IsTerrainPathable(udg_ProjectileCoords[0],udg_ProjectileCoords[1],PATHING_TYPE_FLYABILITY) == true then
                  • Unit Group - Remove ProjectileDummy from ProjectileGroup
                  • Unit - Remove ProjectileDummy from the game
                  • Custom script: call RemoveUnit(udg_ProjectileDummy)
                  • Custom script: endif
                  • -------- IF IT IS KEEP GOING --------
                  • Custom script: call SetUnitX(udg_ProjectileDummy,udg_ProjectileCoords[0])
                  • Custom script: call SetUnitY(udg_ProjectileDummy,udg_ProjectileCoords[1])
                  • -------- LEAK CLEARING/CLEANUP --------
                  • Custom script: call RemoveLocation(udg_ProjectileLocation)
                  • Custom script: call RemoveLocation(udg_ProjectileLocationOffset)
                  • -------- We add locust after so that we can manipulate the projectile --------
                  • Unit - Add Locust Swarm to ProjectileDummy
          • Custom script: call RemoveLocation(udg_ProjectileGroupLoc)
          • Custom script: call GroupClear(udg_ProjectileTempGroup)
          • Custom script: call DestroyGroup (udg_ProjectileTempGroup)
I'm also fairly certain I'm not doing this the most efficient and best way possible, infact, it's kind of hacky, but it works as is.


Thanks and happy holidays.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
All these leak:

  • Set ProjectileLocationOffset = ((Position of ProjectileDummy) offset by (Load 1 of ProjectileID from ProjectileTable) towards (Load 2 of ProjectileID from ProjectileTable) degrees)
  • Set ProjectileGroupLoc = ((Position of ProjectileDummy) offset by (Load 1 of ProjectileID from ProjectileTable) towards (Load 2 of ProjectileID from ProjectileTable) degrees)
  • (Distance between (Position of (Picked unit)) and (Position of ProjectileDummy)) Less than or equal to ProjectileSize
  • Set ProjectileLocationOffset = ((Position of ProjectileDummy) offset by (Load 1 of ProjectileID from ProjectileTable) towards (Load 2 of ProjectileID from ProjectileTable) degrees)
 
Status
Not open for further replies.
Top