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

[Trigger] Unit Group doesn't leak?

Status
Not open for further replies.
Level 20
Joined
Jul 12, 2010
Messages
1,717
Alright guys so I'm like 90% sure this doesn't leak but I wanted to have the opinions of others just to be sure.

  • Power of Darkness loop
    • Events
      • Time - Every 6.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in PowerOfDarkness_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Set VariableSet Local_p1 = (Position of (Picked unit))
              • Unit - Create 1 Dark Orb for (Owner of (Picked unit)) at Local_p1 facing Default building facing degrees
              • Unit - Add a 6.00 second Generic expiration timer to (Last created unit)
              • Custom script: call RemoveLocation(udg_Local_p1)
            • Else - Actions
Every 6 seconds it picks all units in the unit group and spawns a dark orb at their position, by logic the unit group doesn't leak because it's being used every 6 seconds.

It's not used for once and then forgotten. (therefore leak)

A simple workout to this would be to just use:
  • Set VariableSet PowerOfDarkness_Group = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Warden))
and then destroy the unit group when finished.

So is my trigger ok or does it leak?
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
I don't think so... where did you set that unit group variable anyway?

Regardless, as long you're done referencing with the variable it should be destroyed based on how many you've created. In your case, only one unit group is generated and you used it for enumerating only. Therefore, it should be destroyed once you're done using it.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,010
I don’t think you understand what a leak actually is. It’s when you create some object (point, effect, group, etc.) and no longer need to use it but don’t destroy/remove the object. The concept of a “leak” is that it’s memory allocated for that object that doesn’t need to be used any more, but you don’t destroy it. If you then overwrite the variable referring to it the object is permanently allocated and can never be removed.
 
Status
Not open for further replies.
Top