New Leak Found: Keeping references to destroyed objects.

Jesus4Lyf

Good Idea™
Reaction score
397
These are memory leaks (but not handle id leaks). You must check the process list to see it leak.
Credits to Troll-Brain for finding the original leak.

This leaks:
JASS:
library Test initializer init

globals
    private group G1
    private group G2
    private group GROUP=CreateGroup()
    private trigger Trig
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("Start")
    call EnableTrigger(Trig)
    call TriggerSleepAction(10.)
    call DisableTrigger(Trig)
    call BJDebugMsg("End")
endfunction

private function DoTheTest takes nothing returns nothing
    //call BJDebugMsg("run")
    set G1=null // With or without this line.
    set G1=CreateGroup()
    call DestroyGroup(G1)
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set Trig = CreateTrigger()
    
    call TriggerRegisterTimerEvent(Trig,0.0,true)
    call TriggerAddAction(Trig,function DoTheTest)
    call DisableTrigger(Trig)
    
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig, function Actions)
endfunction

endlibrary
In fact, even this leaks:
JASS:
library Test initializer init

globals
    private group G1
    private group G2
    private group GROUP=CreateGroup()
    private trigger Trig
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("Start")
    call EnableTrigger(Trig)
    call TriggerSleepAction(10.)
    call DisableTrigger(Trig)
    call BJDebugMsg("End")
endfunction

globals
    boolean k=false
endglobals

private function DoTheTest takes nothing returns nothing
    //call BJDebugMsg("run")
    if k then
        set G1=null
    else
        set G1=CreateGroup()
        call DestroyGroup(G1)
    endif
    set k = not k
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set Trig = CreateTrigger()
    
    call TriggerRegisterTimerEvent(Trig,0.01,true)
    call TriggerAddAction(Trig,function DoTheTest)
    call DisableTrigger(Trig)
    
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig, function Actions)
endfunction

endlibrary
This does not leak:
JASS:
library Test initializer init

globals
    private group G1
    private group G2
    private group GROUP=CreateGroup()
    private trigger Trig
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("Start")
    call EnableTrigger(Trig)
    call TriggerSleepAction(10.)
    call DisableTrigger(Trig)
    call BJDebugMsg("End")
endfunction

private function DoTheTest takes nothing returns nothing
    //call BJDebugMsg("run")
    set G1=CreateGroup()
    call DestroyGroup(G1)
    set G1=null
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set Trig = CreateTrigger()
    
    call TriggerRegisterTimerEvent(Trig,0.0,true)
    call TriggerAddAction(Trig,function DoTheTest)
    call DisableTrigger(Trig)
    
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig, function Actions)
endfunction

endlibrary
What's the exact cause? Discuss. I will update this post as conclusions are reached and verified.

This is a minor leak.

Conclusion:
Not allowing a handle id to be recycled immediately after destruction causes a memory leak.
 

Jesus4Lyf

Good Idea™
Reaction score
397
I have a new conclusion. We know that the handle id recycler will pick up a handle at any point after it has been destroyed, when its reference count hits 0.

Well, it seems if that is not immediately after it is destroyed, then it causes a leak.

I conclude this because setting the variable to "GROUP" (a constant group) also stops the leak.

Edit: Yep.
Does not leak:
JASS:
library Test initializer init

globals
    private group G1
    private group G2
    private group GROUP=CreateGroup()
    private trigger Trig
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("Start")
    call EnableTrigger(Trig)
    call TriggerSleepAction(10.)
    call DisableTrigger(Trig)
    call BJDebugMsg("End")
endfunction

private function OtherTest takes nothing returns nothing
    local group g=CreateGroup()
    call DestroyGroup(g)
    set g=null
    call TriggerSleepAction(0)
endfunction

private function DoTheTest takes nothing returns nothing
    //call BJDebugMsg("run")
    call OtherTest.execute()
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set Trig = CreateTrigger()
    
    call TriggerRegisterTimerEvent(Trig,0.0,true)
    call TriggerAddAction(Trig,function DoTheTest)
    call DisableTrigger(Trig)
    
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig, function Actions)
endfunction

endlibrary
Does leak:
JASS:
library Test initializer init

globals
    private group G1
    private group G2
    private group GROUP=CreateGroup()
    private trigger Trig
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("Start")
    call EnableTrigger(Trig)
    call TriggerSleepAction(10.)
    call DisableTrigger(Trig)
    call BJDebugMsg("End")
endfunction

private function OtherTest takes nothing returns nothing
    local group g=CreateGroup()
    call DestroyGroup(g)
    call TriggerSleepAction(0)
    set g=null
endfunction

private function DoTheTest takes nothing returns nothing
    //call BJDebugMsg("run")
    call OtherTest.execute()
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set Trig = CreateTrigger()
    
    call TriggerRegisterTimerEvent(Trig,0.0,true)
    call TriggerAddAction(Trig,function DoTheTest)
    call DisableTrigger(Trig)
    
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig, function Actions)
endfunction

endlibrary
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
I still don't see why you would want to destroy a global group, but it is probably an example that applies to handles in general?
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
So the conclusion is: Even globals have to be nulled after destruction.

One question: Does this leak? If yes, then globals have to be nulled immediately and not only inside the same instance.

JASS:

set G1 = CreateGroup()
call DestroyGroup(G1)
call DoNothing()
set G1 = null
 

Jesus4Lyf

Good Idea™
Reaction score
397
This also leaks (demo using hashtables):
JASS:
library Test initializer init

globals
    private group G1
    private group G2
    private group GROUP=CreateGroup()
    private trigger Trig
    private hashtable H=InitHashtable()
endglobals

private function Actions takes nothing returns nothing
    call BJDebugMsg("Start")
    call EnableTrigger(Trig)
    call TriggerSleepAction(10.)
    call DisableTrigger(Trig)
    call BJDebugMsg("End")
endfunction

private function DoTheTest takes nothing returns nothing
    call SaveGroupHandle(H,0,0,CreateGroup())
    call DestroyGroup(LoadGroupHandle(H,0,0))
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    set Trig = CreateTrigger()
    
    call TriggerRegisterTimerEvent(Trig,0.0,true)
    call TriggerAddAction(Trig,function DoTheTest)
    call DisableTrigger(Trig)
    
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig, function Actions)
endfunction

endlibrary
This does not leak (hashtables):
JASS:
private function DoTheTest takes nothing returns nothing
    call SaveGroupHandle(H,0,0,CreateGroup())
    call DestroyGroup(LoadGroupHandle(H,0,0))
    call SaveGroupHandle(H,0,0,GROUP)
endfunction

Neither does this:
JASS:
private function DoTheTest takes nothing returns nothing
    call SaveGroupHandle(H,0,0,CreateGroup())
    call DestroyGroup(LoadGroupHandle(H,0,0))
    call RemoveSavedHandle(H,0,0)
endfunction

>One question: Does this leak? If yes, then globals have to be nulled immediately
No, it does not (tested). But remember, nulling after a wait does (if the handle is removed during the wait).

So the conclusion is solid?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Tested. Setting a variable(contains destroyed value) to a new value will cause leaking.
 

Azlier

Old World Ghost
Reaction score
461
Nay, Blizzard only fixes things that affect their income. Virus maps, yeah, suing could happen there. But a minor memory leak that people found out about eight years later? I don't think so.
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
Then why did they fix local masking? I can't see how that would affect their income.
 

Viikuna

No Marlo no game.
Reaction score
265
Actually, according to Vexorian, local masking works perfectly now. ( link )

Noone really knows what Blizzard is doing and why...
 

Azlier

Old World Ghost
Reaction score
461
>Then why did they fix local masking?

Because apparently typecasting could be done via shadowing. So Blizzard decided to fixit. Or something.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
I guess that at least (partially) explains the slow memory increases of supposedly leak free maps that aren't increasing in active object count.

On the plus side, these leaks are tiny and generally preventable.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Oh hey look, a new leak...
Just another thing I need to learn how to fix. OH WELL.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Oh hey look, a new leak...
Just another thing I need to learn how to fix. OH WELL.
It's not that hard, just set to null the handle variable just after you have destroyed the handle, or flush gamecache/hashtable if you used it instead of a variable.

According to Jesus4Lyf you might can do it after few lines of code without waits, but i recommend to set to null in the line just below the handle destruction, just to be sure, at least it's more likely you won't forget it.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Yeah, well... It's still another thing to remember. And I'm really bad at remembering...
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
If you just recycle what can be recycled in a practical manner you should be fine. That's more efficient anyway than create and destroy, and results in cleaner end code (ie no need to null anything). Global group + GroupClear for instant-use groups, GroupUtils or some other recycler for other groups, TU and maybe T32 for timers depending on what you are doing/need, etc.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top