• 🏆 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] Event Trigger Leaks

Status
Not open for further replies.
Level 4
Joined
Dec 9, 2008
Messages
52
Hi. This code is used for various damage-detection functions. Do I need to store these triggers and then manually destroy them once their unit is destroyed?

  • addunittakesdamage
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Trigger - Add to proximity agitation <gen> the event (Unit - (Entering unit) Takes damage)
      • Trigger - Add to snare <gen> the event (Unit - (Entering unit) Takes damage)
      • Trigger - Add to ko <gen> the event (Unit - (Entering unit) Takes damage)
      • Trigger - Add to arrowhit <gen> the event (Unit - (Entering unit) Takes damage)
Edit: Did some tests. It does indeed leak a lot. 40,000 units created->removed->nulled while this trigger was in effect caused a memory usage increase of about 50-60 mb.
 
Last edited:
Level 19
Joined
Feb 25, 2009
Messages
2,004
Try these:

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Point = (Center of (Playable map area))
      • Set DamageGroup = (Units within 99999.00 of Point matching (((Matching unit) is alive) Equal to True))
      • Unit Group - Pick every unit in DamageGroup and do (Actions)
        • Loop - Actions
          • Trigger - Add to <Trigger> the event (Unit - (Picked unit) Takes damage)
      • Custom script: call RemoveLocation (udg_Point)
      • Custom script: call DestroyGroup (udg_DamageGroup)
And:

  • Detection
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
    • Actions
      • Trigger - Add to <Trigger> the event (Unit - (Triggering unit) Takes damage)
 
Level 4
Joined
Dec 9, 2008
Messages
52
Thanks for the response, but my question wasn't how do I use that trigger, rather it was how do I stop that trigger from leaking.

This is why it leaks: Every time an event is added to those damage-detection triggers, that event is there forever. So if you have 40,000 units over the course of a game, there are going to be 40,000 events for each of those triggers. This is going to cause a huge memory leak.

My questions are 1) how do I remove an event from a trigger and 2) how do I store an event. There isn't a hashtable function SaveEventHandle(...) because initially I wanted to just use a unit's handleid as a key in a hashtable to retrieve that unit's own damage event.

Any ideas?
 
Level 7
Joined
Jul 18, 2009
Messages
272
You can't remove events from triggers.

But I've read somewhere (can't find it right now, sorry) that you can destroy triggers with Jass and create a new one (that only has the events you want).
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Dont destroy triggers.
Think about it, why didnt blizzard make a GUI function to destroy trigger?
Because it is bugged! It can fuck up your handle stack, which might be a hard word for you, but it is serious and fucks up the whole game..
Dont destroy triggers,
There is nothing you can do about the leaks, except for using an advanced vJass Damage System..
 
Level 13
Joined
Mar 16, 2008
Messages
941
Dont destroy triggers.
Think about it, why didnt blizzard make a GUI function to destroy trigger?
Because it is bugged! It can fuck up your handle stack, which might be a hard word for you, but it is serious and fucks up the whole game..
Dont destroy triggers,
There is nothing you can do about the leaks, except for using an advanced vJass Damage System..

Have you ever had problems with this?
All people mention it, but most of them have never faced this rare problem. The only thing to care about is, that no instanc of the trigger is running while destroying it, meaning to wait and not destroy itself. Dota uses MANY dynamic triggers, and although Dota sucks sooooo heavily and Frogs methods are sooooo bad, it works.
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Have you ever had problems with this?
All people mention it, but most of them have never faced this rare problem. The only thing to care about is, that no instanc of the trigger is running while destroying it, meaning to wait and not destroy itself. Dota uses MANY dynamic triggers, and although Dota sucks sooooo heavily and Frogs methods are sooooo bad, it works.

No i have not had problems with it, because i dont make maps..
But if you want to risk your game getting fucked up, go ahead..
 
Level 9
Joined
Apr 28, 2009
Messages
538
Dont destroy triggers.
Think about it, why didnt blizzard make a GUI function to destroy trigger?
Because it is bugged! It can fuck up your handle stack, which might be a hard word for you, but it is serious and fucks up the whole game..
Dont destroy triggers,
There is nothing you can do about the leaks, except for using an advanced vJass Damage System..

It never "fucked up" any of my maps.
And i have a lot of triggers ending with this line:

  • Custom script: call DestroyTrigger(GetTriggeringTrigger())
 
Level 4
Joined
Dec 9, 2008
Messages
52
Ok I looked at TriggerHappy's link and the code DOES destroy triggers. It basically makes a detect damage trigger for each unit that is on the map and then destroys that trigger when the unit is gone.
 
Status
Not open for further replies.
Top