• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] Question About Leaks

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
The force will be removed and not leak.
The handle ID used by the force however might persist and leak unless you eithor eventually reuse the variable with another force or set it to null.

This is because it only recycles handle indexes once all references to it are nulled, and that includes global and local variables.

As long as the variable is reused it will not leak, the handleID leak is only a problem for once off coding.
 
Level 9
Joined
Jun 25, 2009
Messages
427
The force will be removed and not leak.
The handle ID used by the force however might persist and leak unless you eithor eventually reuse the variable with another force or set it to null.

This is because it only recycles handle indexes once all references to it are nulled, and that includes global and local variables.

As long as the variable is reused it will not leak, the handleID leak is only a problem for once off coding.

So let's say, i put the actions in the command -cs, then write the integer(cs) to the player group converted in one player, then destroy force, will it leak? :)

EDIT: It should a little like this.
  • Creep Stats
    • Events:
      • Player - Player 2 (Blue) types -cs as an exact match
      • Player - Player 3 (Teal) types -cs as an exact match
    • Conditions:
    • Action:
      • Set Group=((Player Group(Owner of (Killing Unit)))
      • Game - Text (Group): (Integer(Cs[Player number of (Triggering Player)]))
      • Custom script: call DestroyForce(udg_Group)
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
The conversion from a player to a player group uses the following function:

JASS:
function GetForceOfPlayer takes player whichPlayer returns force
    local force f = CreateForce()
    call ForceAddPlayer(f, whichPlayer)
    return f
endfunction

It declares a local handle variable (force) and fails to null that variable. This will cause a leak.

Everything else is leak-free.
 
Status
Not open for further replies.
Top