• 🏆 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, leaks?

Status
Not open for further replies.
Level 11
Joined
Mar 18, 2009
Messages
788
Hi
I'm making a spell that will use Unit groups and was wondering if it leaks. It will use 2 triggers and has different events.

First we have:
[trigger=Example 1]Example 1
Events
Unit - A unit Starts the effect of an ability
Conditions
Actions
Unit Group - Add (Triggering unit) to ExampleGroup[/trigger]

Then:
[trigger=Example 2]Example 2
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in ExampleGroup and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Then - Actions
Else - Actions
Unit Group - Remove (Picked unit) from ExampleGroup[/trigger]

These are just plain examples of the spell and I don't know if they will leak or something. Thanks!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Unit groups only have 3 leaks as far as I know.
1. Losing all pointers to the group before destroying results in it never being destroyable (as you can not refrence it) and so it will remain for the rest of the session in memory (leak).
2. Failing to null a local group variable before end of function results in whatever group it was pointing (destroyed or otherwsie) being unable to have the pointer identifier from being recycled (handle index leak).
3. Deing units do not get removed from a group automatically so you can cause unit identifiers to leak inside a group. Solutions to this leak are to remove the unit from it on death, to rebuild the group (clear and add everything to it that is a valid unit) or simply destroy the group.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If the Unit Group is used so many times in the map without changing its functionality, you can keep using the Unit Group without the "set bj_wantDestroyGroup = true" because that is for temporary use of Unit Group but this one gonna be used until the game ends, so, it doesn't leak
 
Status
Not open for further replies.
Top