Does this leak?

Discussion in 'JASS Zone' started by afisakov, Oct 6, 2014.

  1. afisakov

    afisakov You can change this now in User CP.

    Ratings:
    +38 / 0 / -0
    would calling unit u cause a leak that needs to be cleaned up?
    Code:
    function CD_atk takes unit u returns nothing
      call GroupAddUnitSimple(u, udg_CoolingDown)
      call PolledWait(0.3)
      call GroupRemoveUnitSimple(u, udg_CoolingDown)
    endfunction
    ...
    call CD_atk(GetAttacker())
    
    Tried to only include the relevant code.
    Also, does the wait create a risk of desync?
     
  2. jonas

    jonas Well-Known Member

    Ratings:
    +42 / 4 / -0
    No. There is no handle leak since parameters do not create handle leaks. There is no regular leak because nothing is created.
     
    • Useful Useful x 1
  3. afisakov

    afisakov You can change this now in User CP.

    Ratings:
    +38 / 0 / -0
    Thank you.
    I wanted to make sure I did not have to add
    set u=null
    at the end of it.
    See that alot when people use local variables and do not fully understand.
     
  4. jonas

    jonas Well-Known Member

    Ratings:
    +42 / 4 / -0
    parameters do not create handle leaks
    local variables create handle leaks
     

Share This Page