• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Solved] Does this unit group leak?

Status
Not open for further replies.
Level 9
Joined
Apr 26, 2011
Messages
403
Hi, I got a question :

if you remove units from game, do it automatic clean up any group it belong to ?

for example:
- CreepGroup is global variable
- Creep will add to this group when it spawn
- creep will remove from game after it die (eg, corpse will dispear after 1 second)

so, do I still need to remove dying creep from CreepGroup ?
or destory CreepGroup at the end of every round ?

or I don't have to because I already removed units from game, so it will automatic clean up any group it belong to ?
 
Level 9
Joined
Apr 26, 2011
Messages
403
You had better check when a unit dies and if it's in that CreepGroup, Unit Group - Remove (Triggering unit) from CreepGroup.

By the way, no, it doesn't leak this way.


Thank, another question:

if I do something like this, do it cause any problem or anything bad :

// clean up group at the end without check which group they belong to
Unit Group - Remove (Triggering unit) from CreepGroup.
Unit Group - Remove (Triggering unit) from GroupA.
Unit Group - Remove (Triggering unit) from GroupB.
Unit Group - Remove (Triggering unit) from GroupC.

or similar : // remove ability without check if they have that ability
unit - remove ability (ability_name) from pick unit
 
Group should be destroyed only if you need them temporary or the instance in which they have been used in has finished. Otherwise, if you make use of global group which is created just to store all creeps spawned it should be not destroyed anytime. In case if you do, you're forced to write:
JASS:
set udg_someDestroyedGroup = CreateGroup()
Or use one of GetUnits(...) functions to be able to use it again.

Things that leak - may be usefull. But consider that using bj_wantDestroyGroup method to destroy groups leaves leaks in you are enumerating units via Units-of-Type function. In this case create and destroy group manually.
 
Level 9
Joined
Apr 26, 2011
Messages
403
Group should be destroyed only if you need them temporary or the instance in which they have been used in has finished. Otherwise, if you make use of global group which is created just to store all creeps spawned it should be not destroyed anytime. In case if you do, you're forced to write:
JASS:
set udg_someDestroyedGroup = CreateGroup()
Or use one of GetUnits(...) functions to be able to use it again.

Things that leak - may be usefull. But consider that using bj_wantDestroyGroup method to destroy groups leaves leaks in you are enumerating units via Units-of-Type function. In this case create and destroy group manually.

I see, I didn't know about CreateGroup() part,

I was though destory group is same as empty unit in group. that is why I worry about group may leaked if I didn't empty it.
 
so, do I still need to remove dying creep from CreepGroup ?
Nope, you dont need to manually remove the units from CreepGroup. It doesn't leak, it just leaves something called "shadow reference", which is a bug with WC3, but nothing really serious to worry about. However, you should Remove the group itself in case it is empty.
 
Status
Not open for further replies.
Top