Leaks

kallieblakie

New Member
Reaction score
5
anyone know what are ALL the things that you would have to remove? My map is causing some leaks and I don't know what else to remove other than unitgroups and locations.


HELP !


EDIT:


Figured it out eventually. Used too much locations, causing lag.

SOLVED!
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
609
Make sure your don't have a lot of units created and make sure you don't have a trigger running every 0.01-2 seconds of the game.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>that's all? but i removed them, and it still lags ! how !
You are using Jass, aren't you?
Forgoten to null handles?
 

Builder Bob

Live free or don't
Reaction score
249
Special Effects
Groups
Points
Units
Regions
Forces
Lightning Effects
Floating Text
Countdown Timers

When on the topic of all things that can leak... I've wondered a long time about this. Does BoolExpr leak if not destroyed, or do they not create a new handle? Like when used in GroupEnumUnitsOfWhatever() functions.
 
Reaction score
456
You probably don't want to destroy a boolexpr. If you do so, then the condition is gone.
 

Builder Bob

Live free or don't
Reaction score
249
Edit2 after some tests:
GroupEnumUnits[...]() use the boolexpr only once, so call DestroyBoolExpr() does not stop the function from working. I'm pretty sure it will leak if not destroyed in this case.
However Destroying boolexpr used in TriggerAddCondition() functions will make the function stop working.

So I guess it depends on if the boolexpr is going to be called once or many times.


On topic:
Are you using many heavy loops and timers that run often? They can cause massive lag if not used with care.
 

kallieblakie

New Member
Reaction score
5
>>that's all? but i removed them, and it still lags ! how !
You are using Jass, aren't you?
Forgoten to null handles?
yeah i nulled handles and effects. nulled bollexpr too. what else? anyone can remind me of something?


I do have triggers running every 0.02 seconds, movement triggers (sliding). does that cause alot of lag? I mainly need to remove the leaks caused by these triggers, right?
 

Builder Bob

Live free or don't
Reaction score
249
yeah i nulled handles and effects. nulled bollexpr too. what else? anyone can remind me of something?


I do have triggers running every 0.02 seconds, movement triggers (sliding). does that cause alot of lag? I mainly need to remove the leaks caused by these triggers, right?

Does your map lag at the very beginning? If yes, then no matter how much or little your map leak, it's not gonna help you to only clear up the leaks. You will need to refine your code to do more with less effort.

A leak is when you use some of your memory, but you don't clean after yourself. At first you won't notice anything since you have so much memory, but after a while it's gonna get quite crowded, and everything is gonna take much longer time to get done. That's when you notice your map leaks.
 

kallieblakie

New Member
Reaction score
5
the map doesn't lag at the begining. it begins to lag after the game gets played longer. doesn't happen when i used GUI, but happened when i convereted it to jass to make it MUI. but now I don't know how to clean up the mess.
 

Builder Bob

Live free or don't
Reaction score
249
Some of the BJ functions leak by not nulling variables. You could check that.

Additions to your list:
Rects
Triggers if created dynamically in your other triggers.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>Some of the BJ functions leak by not nulling variables. You could check that.
O rly?
BJ functions do leak? Which function?

>>but happened when i convereted it to jass to make it MUI
Well, just converting a GUI to Jass won't make any different in speed/lag. Did you done some fatal edit on the code?
 

kallieblakie

New Member
Reaction score
5
ok thanks alot.

it still lags, i don't know why.

i used local variables:

timer
unit
real
integer
location
boolexpr
group
effect.

i only null units, group, effect, location, timer. Didn't null integer and reals. could they be the cause?

EDIT:

Just to check, the code for nulling handles is

JASS:
call FlushHandleLocals(<name>)


right?
 

kallieblakie

New Member
Reaction score
5
i changed the scripting from GUI "2 triggers" to JASS "1 trigger", meaning i completely rewrote the whole trigger, changing from global variables to local variables.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>Just to check, the code for nulling handles is
False.
Syntax:
JASS:
set <HandleName> = null


>>i changed the scripting from GUI "2 triggers" to JASS "1 trigger", meaning i completely rewrote the whole trigger, changing from global variables to local variables.
Nothing I can help unless you post your code.
 

Builder Bob

Live free or don't
Reaction score
249
>>Some of the BJ functions leak by not nulling variables. You could check that.
O rly?
BJ functions do leak? Which function?

Here's one where the variable g is not nulled:
JASS:
function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)

    return result
endfunction
For the most part I've just read about people telling that BJ functions doesn't null variables. It wasn't hard to find this function though, so there are probably more.


For kallieblakie:
JASS:
function PreventTimerLeak takes nothing returns nothing
	local timer t = CreateTimer()
	call DestroyTimer(t)
	set t = null
endfunction

function PreventGroupLeak takes nothing returns nothing
	local timer g = CreateGroup()
	call DestroyGroup(g)
	set g = null
endfunction


These two functions doesn't do anything other than create a timer/group, and then cleaning in the memory. Between the creation and destruction you can do whatever you want with them.
And no, integers, reals and booleans does not have to be nulled.
 

kallieblakie

New Member
Reaction score
5
JASS:

function Arrow_Filter takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true and GetWidgetLife(GetFilterUnit()) > 0.405 
endfunction

function Trig_Arrow_Elunes_Arrow_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'AOsh' ) ) then
        return false
    endif
    return true
endfunction

function DPP takes location locA, location locB returns real
    local real dx = GetLocationX(locB) - GetLocationX(locA)
    local real dy = GetLocationY(locB) - GetLocationY(locA)
    return SquareRoot(dx * dx + dy * dy)
endfunction

function Arrow_Move takes nothing returns nothing
    local timer Loop = GetExpiredTimer()
    local unit arrow = GetHandleUnit(Loop, "arrow")
    local unit caster = GetHandleUnit(Loop, "caster")
    local real angle = GetHandleReal(Loop, "angle")
    local integer Range = GetHandleInt(Loop, "Range")
    local integer Radius = GetHandleInt(Loop, "Radius")
    local real Speed = GetHandleReal(Loop, "Speed")
    local integer PlayerNo = GetHandleInt(Loop, "PlayerNo")
    local real distanceCurrent = GetHandleReal(Loop, "distanceCurrent")
    local location C = GetUnitLoc(arrow)
    local location Next
    local boolexpr b = Condition(function Arrow_Filter)
    local real x 
    local real y
    local group g = CreateGroup()
    local unit p
    local integer Number
    local location locA = GetUnitLoc(caster)
    local location locB = GetUnitLoc(arrow)
    if  (R2I(distanceCurrent) <= Range) then
       set distanceCurrent = distanceCurrent + Speed
       call SetHandleReal (Loop, "distanceCurrent", distanceCurrent)
       set x = GetLocationX(C) + Speed*Cos(angle*bj_DEGTORAD)
       set y = GetLocationY(C) + Speed*Sin(angle*bj_DEGTORAD)
       set Next = Location(x,y) 
       call SetUnitPositionLoc( arrow, Next )
       call GroupEnumUnitsInRangeOfLocCounted(g, Next, I2R(Radius), b, 1)
        set Number = CountUnitsInGroup(g)
        if Number > 0 then
           set p = FirstOfGroup(g)
              
             if ( ( UnitHasBuffBJ(p, 'BPSE') == true ) ) then
               call UnitDamageTarget(caster, p, 100000, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
               call RemoveUnit(arrow)
             elseif ( (IsUnitEnemy(p, GetOwningPlayer(caster)) == true)) then
               call RemoveUnit(arrow)
               call UnitDamageTarget(caster, p, udg_Damage[PlayerNo], false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
       
            call CreateNUnitsAtLoc( 1, 'hfoo', GetOwningPlayer(caster), Next, 0.00 )
            call UnitAddAbilityBJ( 'ANsb', GetLastCreatedUnit() )
            call SetUnitAbilityLevelSwapped( 'ANsb', GetLastCreatedUnit(), udg_Stun[PlayerNo] )
            call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", p )
            call UnitApplyTimedLifeBJ( 2.00, 'BTLF', GetLastCreatedUnit() )

  call UnitDamageTarget (caster, p, (( I2R(udg_I_PrecisionLevel[PlayerNo]) * ( 0.06 * DPP(locA,locB)))+( ( 35000.00 * ( 0.40 * I2R(udg_I_bladeLevel[PlayerNo]) ) ) / DPP(locA,locB))),false,true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_HEAVY_BASH )
          set arrow = null
          set caster = null
          set p = null
            call RemoveLocation (locA)
            call RemoveLocation (locB)
            call FlushHandleLocals(Loop)
            call PauseTimer(Loop)
            call DestroyTimer(Loop)
            call RemoveLocation (Next)
            call RemoveLocation (C)
    set x = 0.00
    set y = 0.00

    call DestroyBoolExpr(b)
    call DestroyGroup(g)
               endif

              

        endif
    call DestroyBoolExpr(b)
    call DestroyGroup(g)
            call RemoveLocation (Next)
            call RemoveLocation (C)        
    set x = 0.00
    set y = 0.00
          set arrow = null
          set caster = null
          set p = null
            call RemoveLocation (locA)
            call RemoveLocation (locB)


    elseif (R2I(distanceCurrent) > Range) then
       call KillUnit(arrow)
       call RemoveUnit(arrow)
       call PauseTimer(Loop) 
       call FlushHandleLocals(Loop)
       call DestroyTimer(Loop) 
    endif
    set x = 0.00
    set y = 0.00
    call RemoveLocation(C)
    call RemoveLocation(Next)
    set arrow = null
    call DestroyBoolExpr(b)
    call DestroyGroup(g)
          set caster = null
          set p = null
            call RemoveLocation (locA)
            call RemoveLocation (locB)
endfunction



function Trig_Arrow_Elunes_Arrow_Actions takes nothing returns nothing
    local timer Loop = CreateTimer()
    local unit caster = GetSpellAbilityUnit()    
    local location casterPosition = GetUnitLoc(caster)
    local location targetPosition = GetSpellTargetLoc()    
    local integer PlayerNo = GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))
    local integer radius = udg_Radius[PlayerNo]
    local real angle = AngleBetweenPoints(casterPosition, targetPosition)
    local real x = GetLocationX(casterPosition) + (radius+2)*Cos(angle*bj_DEGTORAD)
    local real y = GetLocationY(casterPosition) + (radius+2)*Sin(angle*bj_DEGTORAD)    
    local real Scale = ( 100.00 * ( I2R(radius) / 80.00 ) )   
    local location shootPosition = Location(x,y) 

    local unit arrow = null
    local integer Range = udg_Range[PlayerNo]
    local real Speed = udg_Speed[PlayerNo]
    call CreateNUnitsAtLoc( 1, 'hpea', ConvertedPlayer(PlayerNo), shootPosition, angle)
    set arrow = GetLastCreatedUnit()
    call SetUnitScalePercent( arrow, Scale, Scale, Scale )
    call SetUnitPathing( arrow, false )
    call RemoveLocation(shootPosition)
    call RemoveLocation(casterPosition)
    call RemoveLocation(targetPosition)    
    set x = 0.00
    set y = 0.00

   call SetHandleHandle(Loop, "arrow", arrow)
   call SetHandleHandle(Loop, "caster", caster)
   call SetHandleReal(Loop,"angle",angle)
   call SetHandleInt(Loop, "Range", Range)
   call SetHandleReal(Loop, "Speed", Speed)
   call SetHandleInt(Loop, "Radius", radius)
   call SetHandleInt(Loop, "PlayerNo", PlayerNo) 
    call TimerStart(Loop, 0.03, true, function Arrow_Move)
endfunction




//===========================================================================
function InitTrig_Arrow_Elunes_Arrow takes nothing returns nothing
    set gg_trg_Arrow_Elunes_Arrow = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Arrow_Elunes_Arrow, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Arrow_Elunes_Arrow, Condition( function Trig_Arrow_Elunes_Arrow_Conditions ) )
    call TriggerAddAction( gg_trg_Arrow_Elunes_Arrow, function Trig_Arrow_Elunes_Arrow_Actions )
endfunction

this is my code. i'm desperate. someone help me check out where it leaks please?

for certain global variables, they are variables that records down each individual player's stats, recoreded in an array.

Please help ! it will be appreciated!
 

SFilip

Gone but not forgotten
Reaction score
634
> Does BoolExpr leak if not destroyed
No, they never leak.
And because of this destroying is a bad idea.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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