| 03-18-2008, 08:49 PM | #1 |
I was wondering how unit event leaks, I've been to the submissions section and read about zen87's attack detect engine , since its impolite and inappropriate to ask on that thread, I decided to make a new one. So If I add multiple units to a single trigger, it would create multiple triggers for every single unit rather than just use a single one? Thanks for any clarifications. |
| 03-18-2008, 08:58 PM | #2 |
i've tried this in a short timer periodic : JASS:local trigger t=CreateTrigger() call TriggerRegisterUnitEvent(t,U,EVENT_UNIT_CONSTRUCT_CANCEL) call DestroyTrigger(t) set t=null and there is no memory leak, so at least it seems when you destroy a trigger an unit event on it dont' leak. But maybe i'm totaly wrong |
| 03-18-2008, 09:09 PM | #3 |
how about multiple units? like for example: JASS:local trigger t=CreateTrigger() call TriggerRegisterUnitEvent(t,U,EVENT_UNIT_CONSTRUCT_CANCEL) call TriggerRegisterUnitEvent(t,I,EVENT_UNIT_CONSTRUCT_CANCEL) call TriggerRegisterUnitEvent(t,D,EVENT_UNIT_CONSTRUCT_CANCEL) call DestroyTrigger(t) set t=null |
| 03-18-2008, 09:13 PM | #4 |
how about to test yourself ? :p Just do it in a short timer, start with grimoire and window mode, and check the memory of the process war3.exe. and don't forget to click on the warcraft window or the game will be paused, but i think there is a way for don't pause it, read the documentation |
| 03-18-2008, 09:16 PM | #5 |
k thanks man update: MEMORY LEAKS per Unit, Wtf! Solved! |
| 03-18-2008, 09:41 PM | #6 | |
Quote:
When you destroy a trigger it destroys all the events associated with it. That means the trigger stores a list of events registered to it. It doesn't remove the event from the trigger when the unit is removed. If you just keep adding unit events the list will therefore keep growing. It's only a problem if you have a long game with a lot of units. |
| 03-19-2008, 04:59 AM | #7 |
Someone mentioned unit events clearing themselves when the unit died. Not sure if that was ever verified though. |
| 03-19-2008, 05:05 AM | #8 | |
Quote:
|
| 03-19-2008, 05:59 AM | #9 |
I did some testing, I found out it did not clean itself. The only way to clean it is if you destroy it. I think that's why blizzard made player unit events. One other question, can we remove single unit events for single units, I'm assuming we can't? |
| 03-19-2008, 06:06 AM | #10 | |
Quote:
|
| 03-19-2008, 06:19 AM | #11 |
Wonderful! lol. Now I know why Attack Detect Systems use single trigger per unit, since you can't clean unit events. |
| 03-19-2008, 10:55 AM | #12 |
They're also massively inefficient. It makes more sense to put small groups of units per trigger, especially for maps where units tend to be created and die in groups. |
| 03-19-2008, 02:46 PM | #13 |
In DoE, I use a single trigger loaded with all of the events for every unit created. I simply destroy and recreate the trigger every time the map rematches, that way the buildup is faint and never amounts to anything significant. Works perfectly. |
| 03-19-2008, 04:23 PM | #14 |
So it's better to add units as a group into the unit event and when everyone in the group is dead, destroy the trigger thereby cleaning the leak; now I get it. One must take into consideration how he will use such events in order to decide which technique to apply. It would have been better if Blizzard was kind enough to make a Player Unit Event for damage detection, I do hope Blizzard tries to improve jass API's on the next patch. |
| 03-19-2008, 04:26 PM | #15 | |
Quote:
|
