Thinking about boolexprs

Magoiche

Member
Once upon a time someone told me that in enum functions a null boolexpr leak.
But i was tinking about that and noticed that when i use some BJ that call a enum function my boolexpr isn't null, so i belive it won't leak. Right?
Or because a BJ it will leak and i have to inline/make it my own function?

Example:

JASS:
    local group PossibleTargets = GetUnitsInRangeOfLocMatching(500.00, CasterLoc, Condition( function TargetAndGroupConditions ) )


Thanks =]
 

Romek

Super Moderator
Staff member
Tinking -> Thinking. :p

I don't quite understand what you're saying.
Null boolexprs do leak. Using your own Filter() or Condition() will prevent that.
The filter can be something as simple as:
JASS:
function True takes nothing returns boolean
return true
endfunction


BJ's which use null leak. ;)
 

Romek

Super Moderator
Staff member
> I'm beginning to see where those rumors are coming from..
Hmm, I never did any testing myself, but I assumed it was true seeing as a lot of good coders agreed with it.
I just did some testing with handle count, and by checking memory usage by Wc3.
Handle count isn't increased no matter when null is used. (Well, tested with events, and GroupEnum. Events increases handle count by 1 each time called. Obviously because the returned event is a handle).
However, memory usage by wc3 does seem to steadily increase when using null for GroupEnum. It doesn't increase at all compared to 'null' when using Filter(function True).

I'll do some more testing and retesting with different functions and stuff. Hopefully I'll be able to come to a safe conclusion.
 

saw792

Is known to say things. That is all.
I also tested this after brazenly declaring all null boolexprs leak myself. My results also show no difference in handle count between an inlined AnyUnitEventBJ() using null and one using a true conditionfunc (which was created for both tests, but only used in one).
 

Viikuna

No Marlo no game.
Yea, I too believe these things when I hear them.

I guess we just need more testing and less talk without testing. ( Too bad Im usually too lazy to test these things. :D )
 

Romek

Super Moderator
Staff member
Well, the handle count doesn't increase (Then again, why would it? No=ones creating handles). But the mem. usage does.
I tested with a 0.01 second timer. First using null, then using Filter(function True).
The memory usage goes up and down occasionally for both tests. But with null, there is generally a bigger increase.
 

Troll-Brain

You can change this now in User CP.
Well, the handle count doesn't increase (Then again, why would it? No=ones creating handles). But the mem. usage does.
I tested with a 0.01 second timer. First using null, then using Filter(function True).
The memory usage goes up and down occasionally for both tests. But with null, there is generally a bigger increase.
Post your code.
 

Romek

Super Moderator
Staff member
Post your code.
JASS:
scope test initializer Init

    globals
        group G = CreateGroup()
    endglobals
    
    function Tr takes nothing returns boolean
        return true
    endfunction

    function Exp takes nothing returns nothing
        call GroupEnumUnitsInRange(G, 0., 0., 0., null)
       // call GroupEnumUnitsInRange(G, 0., 0., 0., Filter(function Tr))
        call BJDebugMsg(".")
    endfunction

    function Init takes nothing returns nothing
        call TimerStart(CreateTimer(), 0.01, true, function Exp)
    endfunction

endscope


Try it yourself. I'm still not entirely convinced though. The memory usage could be going up for other reasons. And it goes up and down for both the filter and null either way. :p

Retested twice. It does seem to go up much more rapidly with null.
 

Troll-Brain

You can change this now in User CP.
Hmm you don't clean the group :p
Also just comment BJDebugMsg if you didn't.

And for group it leaks it is sure 100 %, if you really want to test, do it with other boolexpr like TriggerRegister.
 

Romek

Super Moderator
Staff member
> Hmm you don't clean the group :p
No need. GroupEnum overwrites the group.
Why would I need to anyway?

The message is uncommented for both tests for me. So it's not the cause of one of them rising faster than the other. :)

Edit: Without the message, the difference is even more noticeable. with Filter(function TR), the memory usage went up by 16 over about 10 seconds. With null it went up by about 200.
 

Troll-Brain

You can change this now in User CP.
> Hmm you don't clean the group :p
No need. GroupEnum overwrites the group.
Why would I need to anyway?

The message is uncommented for both tests for me. So it's not the cause of one of them rising faster than the other. :)

Edit: Without the message, the difference is even more noticeable. with Filter(function TR), the memory usage went up by 16 over about 10 seconds. With null it went up by about 200.
Yes you're right for the GroupClear.
But i've tested and the memory doesn't go up for me with the true filter, but it leaks with the null boolexpr, but i don't display strings, and so didn't test if the handles go up or not.
 

Romek

Super Moderator
Staff member
> But i've tested and the memory doesn't go up for me with the true filter, but it leaks with the null boolexpr

Same results as I got.

> and so didn't test if the handles go up or not.
Put this in your code somewhere. The HandleCounter I used. :)
JASS:
globals
        leaderboard udg_HandleBoard
endglobals

function HandleCounter_L2I takes location P returns integer
        return P
        return 0
endfunction

function HandleCounter_Update takes nothing returns nothing
        local integer i = 0
        local integer id
        local location array P
        local real result=0
        loop
                exitwhen i >= 50
                set i = i + 1
                set P<i> = Location(0,0)
                set id = HandleCounter_L2I(P<i>)
                set result = result + (id-0x100000)
        endloop
        set result = result/i-i/2
        loop
                call RemoveLocation(P<i>)
                set P<i> = null
                exitwhen i &lt;= 1
                set i = i - 1
        endloop
        call LeaderboardSetItemValue(udg_HandleBoard,0,R2I(result))
endfunction

function HandleCounter_Actions takes nothing returns nothing
        set udg_HandleBoard = CreateLeaderboard()
        call LeaderboardSetLabel(udg_HandleBoard, &quot;Handle Counter&quot;)
        call PlayerSetLeaderboard(GetLocalPlayer(),udg_HandleBoard)
        call LeaderboardDisplay(udg_HandleBoard,true)
        call LeaderboardAddItem(udg_HandleBoard,&quot;Handles&quot;,0,Player(0))
        call LeaderboardSetSizeByItemCount(udg_HandleBoard,1)
        call HandleCounter_Update()
        call TimerStart(GetExpiredTimer(),0.05,true,function HandleCounter_Update)
endfunction

//===========================================================================
function InitTrig_HandleCounter takes nothing returns nothing
        call TimerStart(CreateTimer(),0,false,function HandleCounter_Actions)
endfunction

</i></i></i></i>


I guess we can come to a conclusion that 'null boolexprs' actually do leak?
 

saw792

Is known to say things. That is all.
We need some way to check memory allocation or something, or at least find out how null boolexprs actually do leak (if they do). Hmm sortof stating the obvious here aren't I...
 

Troll-Brain

You can change this now in User CP.
We need some way to check memory allocation or something, or at least find out how null boolexprs actually do leak (if they do). Hmm sortof stating the obvious here aren't I...
Al least they do leak for Groups but not for TriggerRegisterPlayerUnitEvent, that's a fact.
 

Romek

Super Moderator
Staff member
> No lol, it's a lame thing for group,
Well, we can come to a conclusion that null boolexpr with groups leaks.

> Needing more tests :p
Here:

JASS:
scope test initializer Init

    globals
        group G = CreateGroup()
        trigger T = CreateTrigger()
    endglobals
    
    function Tr takes nothing returns boolean
        return true
    endfunction

    private function Exp takes nothing returns nothing
        //call TriggerRegisterPlayerUnitEvent(T, Player(0), EVENT_PLAYER_UNIT_DEATH, null)
        call TriggerRegisterPlayerUnitEvent(T, Player(0), EVENT_PLAYER_UNIT_DEATH, Filter(function Tr))
        //call GroupEnumUnitsInRange(G, 0., 0., 0., null)
       // call GroupEnumUnitsInRange(G, 0., 0., 0., Filter(function Tr))
    endfunction

    private function Init takes nothing returns nothing
        call TimerStart(CreateTimer(), 0.01, true, function Exp)
    endfunction

endscope

I tried that. It's much more difficult to see because of the handle being created every 0.01 seconds. Although, yet again. The null one seems to increase memory usage much more rapidly.
 

Troll-Brain

You can change this now in User CP.
But you leak events, your test is bad.
That's why i destroy and create a new trigger all the time in the test code.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • tom_mai78101 tom_mai78101:
    Would like to get some annual forum statistics report.
  • The Helper The Helper:
    there are stats in the xenforo forum admin section and we have matomo stats we started collecting beginning of the year so we will not have annual on that until next year
  • The Helper The Helper:
    I thought you had keys to the bathroom Tom? Ghan does Tom have access to the stats thread in the bathroom
  • The Helper The Helper:
    since I started jacking with the bots on the site we doubled our page views on the site in a week lol
  • The Helper The Helper:
    I have been having lots of fun
  • The Helper The Helper:
    we have had like 6000 views of the American Airlines economy class thread in the last week
  • The Helper The Helper:
    I ought to stick a travel affiliate link or something on that page to try and monetize that they are just going there and leaving it might even be bots I am not sure
  • The Helper The Helper:
    I just got into it with the Atari VCS Facebook Moderator I started trolling him and almost got banned
  • The Helper The Helper:
    They deleted one of my posts one time so I was trolling him on a help post I put up because I am evil I guess and bored and the guy handled it well I loved his attitude Atari has a good social media presence even if they do not have many games.
  • The Helper The Helper:
    The French Atari they call them even though they are like totally based in America they just have French Money coming in. Gotta love it
  • Ghan Ghan:
    Microsoft buying Activision Blizzard holy crap!
  • The Helper The Helper:
    I know right holy cow
  • Accname Accname:
    Thats not going to save it.
  • The Helper The Helper:
    It might
  • The Helper The Helper:
    They are going to use alot of that IP in the Metaverse
  • The Helper The Helper:
    I found a new section of the stats that is freaking interesting!
  • The Helper The Helper:
    oh yeah this is what I was looking for good job matomo! These are some sweet stats I am learning the interface on it too!
  • The Helper The Helper:
    If anyone ever asks later how I found out about it was watching the site bots but not watching what they were doing but asking myself why they were here?
  • The Helper The Helper:
    there must be a reason and ok that is it
  • The Helper The Helper:
    the past and the future all come together into one
  • The Helper The Helper:
    the search engines are what built thehelper.net the search engines will make it big again maybe
  • The Helper The Helper:
    the real question is are 5 million links better than 60 real good links?
  • The Helper The Helper:
    the answer is 60 lol
  • The Helper The Helper:
    unless you put 100k links on it lol then you get something

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome
    Top