• 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.

Safely unregistering dynamically created triggers

Status
Not open for further replies.
Level 3
Joined
Aug 4, 2012
Messages
22
Ok. Here's the situation. So I'm creating units and I need to attach "RegisterUnitInRange" events dynamically to these units. So I'm using a snippet from here to accomplish that.

That part is simple. These created units are removed after sometime. So I think to myself, I should probably unregister the events before removing the units from the map.

But I remembered that destroying dynamic triggers can sometime cause handle corruption which can lead to fatals etc. And UnregisterUnitInRangeEvent in the above snippet does utilize destroytrigger for cleaning up purposes.

So how should I handle this situation? do I:

  1. Let the triggers leak?
  2. Unregister the event anyway?
 
The handle stack corruption bug relates specifically to DestroyTrigger() when used alongside TriggerSleepAction().
http://www.wc3c.net/showpost.php?p=1132590&postcount=5

Otherwise, as far as we know it is safe. In this case, it would make sense to unregister the event using UnregisterUnitInRangeEvent (in that system). You don't know how many event you could be making--it could be just 1. Or it could be 10000 over the course of the map. Just to be safe (and memory efficient), you should clear them. :)
 
Status
Not open for further replies.
Top