Thinking about boolexprs

Magoiche

Member
Reaction score
20
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 =]
 

Builder Bob

Live free or don't
Reaction score
249

Romek

Super Moderator
Reaction score
963
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
Reaction score
963
> 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.
Reaction score
280
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.
Reaction score
265
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
Reaction score
963
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.
Reaction score
85
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
Reaction score
963
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.
Reaction score
85
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
Reaction score
963
> 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.
Reaction score
85
> 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
Reaction score
963
> 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.
Reaction score
280
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.
Reaction score
85
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
Reaction score
963
> 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.
Reaction score
85
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.
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top