boolexpr
From WarCraft3
Template:common.j article series
Contents |
Memory Leaks
Despite what many coders think, boolexpr variables created through Condition or Filter do not leak any more than a string would, as they are recycled. When a boolexpr is first created, it is placed in the memory. However, future Condition/Filter boolexprs that use the same function such as this:
Condition(function ReturnTrue)
will return the existing boolexpr, rather than create a new one. For this reason, it is not necessary to destroy boolexprs created with Condition/Filter.
However, there are also ways to create boolexprs from other boolexprs:
These return a new boolexpr. This boolexpr will not be reused, and thus should be removed and have all variables pointing to it nulled in order to avoid a memory leak.
Group Enumeration Leaks
Group enumeration functions caused a memory leak before patch 1.24 if null was used as the boolexpr argument. To avoid this, a coder would often resort to creating a garbage boolexpr function that returns true, to be used instead of null.
function ReturnTrue takes nothing returns boolean
return true
endfunction
This no longer applies since Blizzard fixed this issue in patch 1.24. You may now input null as a boolexpr argument freely without worry of a memory leak.