Note that there are some explanatory texts on larger screens.

plurals
  1. POpython memory leak, leaking frames
    primarykey
    data
    text
    <p>I have this code to get the caller of my function's file name, line number, and function. It seems to be leaking frames though and I don't understand why. Is this just throwing me off and my leak must be elsewhere?</p> <pre><code> rv = "(unknown file)", 0, "(unknown function)" for f in inspect.stack()[1:]: if __file__ in f: continue else: rv = f[1:4] break return rv </code></pre> <p>I'm not saving a reference to the frame anywhere. But it's definitely frames that are leaking:</p> <pre> > objcallgraph.show_most_common_types() >tuple 24798 >frame 9601 >... </pre> <p><em>Update</em>: My frames are definitely being leaked. I did the suggestion about gc.set_debug() and frames are very slowly going into the gc.garbage list. Not even close to how many are being created though as show in show_most_common_types(). I have a question about scope though, in the above, doesn't <code>f</code> go out of scope after the for loop? Because I just tried this:</p> <pre><code> for f in range(20): l = 1 print f </code></pre> <p>and it printed 19. So could it be my <code>f</code> in the for loop leaking? This is a reference graph of a frame reference that was in my gc.garbage list:</p> <p><img src="https://i.stack.imgur.com/CxelP.png" alt="alt text"></p> <p><em>Update2</em>:</p> <p>It looks like the inspect module itself is holding references to the frames. This is an objectgraph of a backreference from a live frame, not one on the garbage list.</p> <p><img src="https://i.stack.imgur.com/UfjQ4.png" alt="alt text"></p> <p>Link <a href="https://i.stack.imgur.com/UfjQ4.png" rel="nofollow noreferrer">here</a> because it's too wide.</p> <p>Is there a way to clear the inspect module? Where the hell are these frames being saved =\</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload