| 04-13-2007, 07:33 PM | #1 |
Ok. Recently, I've learned that JASS leak boolexpr when they have conditions: JASS:function JASS_Conditions takes nothing returns boolean if ( not (GetUnitTypeID ( 'n000' == ) then //This is just a random thing// endfunction function JASS_Actions takes nothing returns nothing //Actions endfunction //================================================ function InitJASS_Trig takes nothing returns nothing set gg_trg_JASS = CreateTrigger( ) TriggerRegisterAnyEvent ( UNIT_IS_ATTACKED ) //Whatever// TriggerAddAction( gg_trg_JASS, function (JASS_Actions)) call TriggerAddCondition( gg_trg_JASS, Condition( function JASS_Conditions )) // <<<<<<<LEAK<<<<<<<// endfunction Simply put: JASS = Condition Leak Fix = Add a Boolexpr GUI = Condition Leak (Yes or No?) Fix = (If so, how?) I hope you understand what I mean. ![]() |
| 04-13-2007, 08:14 PM | #2 |
Condition() returns a boolexpr, so its creating one. Now, when used in a situation like a condition for a trigger, you don't have to worry about a leak. This is because the trigger is not likely to be destroyed, so why would the boolexpr? Condition() also has a chaching mechanism, which means it will return the same thing each time its called with the same argument. It won't create a new boolexpr. The only time this would actually become an issue is when you create triggers dynamically, and even there, with Condition()'s caching, you don't need to worry about it. A memory leak is an object left in memory that serves no purpose. Why would you destroy a boolexpr thats still being used as a condition for a trigger? |
| 04-13-2007, 08:42 PM | #3 |
OK... Thanx! ![]() |
| 04-13-2007, 09:01 PM | #4 | |||
Quote:
Ehum, you state something then go against it. You said: Quote:
Then you say: Quote:
|
| 04-13-2007, 09:24 PM | #5 |
Condition() doesn't leak, and it is actually risky to remove BoolExprs created by it. triggercondition object created by TriggerAddCondition does leak, but you are using it for as long as the trigger is active, which would be the whole game, that isn't a memory leak. |
| 04-13-2007, 09:27 PM | #6 |
Yeah, my explination kinda sucked. They can't all win emys. Condition() will create a new boolexpr if one has not been created for that function alredy. Which means it does create something, but only once. Atleast, thats how i understand it. Its a messed up little function. |
| 04-13-2007, 09:41 PM | #7 |
@Vexorian: Thanx +rep as well. @Earth-Fury: Thanx. ![]() |
