| 03-19-2007, 08:24 PM | #1 |
Ok, so leaking in functions is all good and fine..simple and relatively straightforward. However, no one ever looks or cares about the conditional "functions" (since they are, after all, functions themselves). Never, EVER have I see anyone worry about the handles extended by native calls (or even, god forbid, a BJ function call). Has nobody ever really thought about it? Or are conditional functions executed with a special "native" parameter that automatically deallocates any handles that are extended as a result of its operation? In any case, just curious. |
| 03-19-2007, 09:05 PM | #2 |
What exactly are you talking about? Trigger Conditions? Boolexprs? An example of this leak perhaps? |
| 03-19-2007, 09:53 PM | #3 |
Trigger conditions. And its not a leak in particular, but the concept that those trigger conditions themselves may leak. |
| 03-19-2007, 11:06 PM | #4 | |
Quote:
JASS:function SomeTrigger_Conditions takes nothing returns boolean return IsUnitIllusion(GetEnumUnit()) endfunction |
| 03-19-2007, 11:39 PM | #5 |
Ah I think I understand...you're asking if there is a memory leak in a function used as a condition for some trigger? A function used this way will run every time the event triggers so yes, it can leak and it is very important to free any memory allocated in it - the game pretty much can't do this on it's own. |
| 03-19-2007, 11:45 PM | #6 |
Im rather sure that WC3 isn't smart enogh to do effective garbage collection at all, let alone in one specific area. So destroying unused handels within conditional functions is probobly a good idea. |
| 03-20-2007, 12:05 AM | #7 |
lol..that's what I thought, I guess its minuscule enough that no one really ever worries about it. I had to satisfy my curiosity though :D |
| 03-20-2007, 12:08 AM | #8 |
Ah, my bad, I was reading this topic and I misunderstood the part about Wrapper Functions. Then that's stupid. Any function that returns a handle leaks a bit, am I right? |
| 03-20-2007, 12:49 AM | #9 | |
Quote:
Any function that reurns a handle that hasnt had all variables referancing it set to null / another value leaks. thats how i understand it. |
| 03-20-2007, 12:58 AM | #10 |
I did a test conditions do leak you need to use it then functions to avoid them... :( |
| 03-20-2007, 12:58 PM | #11 |
Botanic, for future reference...use punctuation in your posts. |
| 03-21-2007, 03:04 AM | #12 | |
Quote:
|
| 03-21-2007, 03:15 AM | #13 |
Well... I'm used to destroy and null all the handles in the condition functions, and I haven't had any side effects for doing that, so I consider healthy doing a memory cleaning in that functions too. Testing filter:function Attacking_Script_IsStructure takes nothing returns boolean local unit u = GetFilterUnit() local boolean b1 = IsUnitType(u, UNIT_TYPE_STRUCTURE) == true local boolean b2 = GetUnitLevel(u) == 0 set u = null return b1 and b2 endfunction As an advantage, I gain readability in the code :) |
