| 03-21-2007, 07:16 PM | #1 |
As my observation skills over the ram are close to null, I was wondering if someone could check or maybe tell me from previous experience what happens with a special effect attached to an unit that dies? It's obvious that the visual effect disappears, but does the effect remain in the memory as an object, and therefore, leak? I doubt that removing the unit via UnitApplyTimedLife or KillUnit makes any difference. The unit does not decay, and cannot be raised (death time = 0.01). Giving all the details as they might prove important in this test. Thanks! ~Daelin |
| 03-21-2007, 10:30 PM | #2 |
Try this, run SFX_DeadTest and see if it prints out a address, if it does, that is most probally a sign of the handle still taking up memory. JASS:function HtoI takes handle H returns integer return H return 0 endfunction function SFX_DeadTest takes nothing returns nothing local unit u = CreateUnit(Player(0), 'hpea', 0., 0., 0.) local effect e = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", u, "origin") call RemoveUnit(u) call BJDebugMsg("Removing Unit, handle ID = "+I2S(HtoI(e))) call DestroyEffect(e) set u = CreateUnit(Player(0), 'hpea', 0., 0., 0.) set e = AddSpecialEffectTarget("Abilities\\Spells\\Human\\Heal\\HealTarget.mdl", u, "origin") call KillUnit(u) call BJDebugMsg("Killing Unit, handle ID = "+I2S(HtoI(e))) call RemoveUnit(u) call DestroyEffect(e) set u = null set e = null endfunction |
| 03-22-2007, 02:32 PM | #3 |
This so doesn't work... not even for units. I've tried tihs before with units, and the code below prints two different adresses: JASS:function Unit_MemoryTest takes nothing returns nothing local unit u = CreateUnit(Player(0), 'h000', 0,0,0) call BJDebugMsg(I2S(GS_H2I(u))) call RemoveUnit(u) call BJDebugMsg(I2S(GS_H2I(u))) set u = CreateUnit(Player(0), 'h000',0,0,0) call BJDebugMsg(I2S(GS_H2I(u))) It printed 1048854 twice and 1048855 once. Explanation? Well, since "u" is only a pointer, even if you remove the unit, it continues to point at the same address. Apparently the following object is created at the next address, even though the current one is available. But the object has been clearly removed. Therefore, even though the code doesn't leak (objects are correctly removed), a different address is displayed for the second object. ~Daelin |
| 03-22-2007, 03:04 PM | #4 |
An effect attached to a unit that is removed will still leak unless destroyed. An effect attached to a dying unit still exists until the effect is destroyed. |
| 03-22-2007, 03:21 PM | #5 | |
Quote:
The problem is that functions don't remove the references of local variables, so there's the not set to null leak . |
| 03-22-2007, 03:31 PM | #6 |
Good to know... thanks for the tips. I made some memory tests too in task manager and it does confirm that effect leaks are just terrible, leading to up to 10 MB of memory leak for only 5000 effects. ~Daelin |
| 03-22-2007, 09:58 PM | #7 |
Excuse me for trying, i'll get more sleep next time. |
