• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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,258
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.
 
Status
Not open for further replies.
Top