Bugs item #808596, was opened at 2003-09-18 15:48
Message generated for change (Settings changed) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=808596&group_id=5470

Category: None
Group: Python 2.3
Status: Open
Resolution: Later
Priority: 2
Submitted By: Michael Hudson (mwh)
Assigned to: Nobody/Anonymous (nobody)
>Summary: apparently leaking snippet

Initial Comment:
Raymond Hettinger found that the following:

 fd, fname = tempfile.mkstemp()
 execfile(fname)

leaks a reference.  TrackRefs sez it's a string. 
Haven't dug any further.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-08-09 14:46

Message:
Logged In: YES 
user_id=6656

Reopening, as it turned out interning filenames did do some
good.

Lowering priority as it isn't a real leak.

It's still kinda annoying, though.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-08-03 11:25

Message:
Logged In: YES 
user_id=6656

Done, in Python/compile.c revision 2.312.

test_pkgimport turned out to be something else 
(sys.path_importer_cache), so I feel no need to try and be clever 
with dummy's refcounting today.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-08-02 16:11

Message:
Logged In: YES 
user_id=80475

Not interning the filename seems cleanest.  Like you, I do
not expect that interning provided any real benefit here.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-08-02 13:56

Message:
Logged In: YES 
user_id=6656

I've finally worked out what's going on here.

It's because compiling the file interns the name of the file being 
compiled.  Now that interned strings are mortal, this isn't a big 
deal, but it still results in a string being added to and removed 
from the interned strings dictionary with net result (almost all of 
the time) of incrementing the refcount on 'dummy' by one.  Once 
in every thousand or so iterations this results in the interned 
string dictionary being resized and throwing all the references to 
dummy away, so this isn't a 'real' leak.

OTOH, I'd still like to do something about this (as is, test_pkg 
appears to leak 10 references per run because of this).  The 
simplest thing would be to just plain not intern the filename during 
compilation (I find it hard to believe that it's of any real 
benefit). The more invasive solution would be to not do 
refcounting on dummy (assuming that's even possible) which is a 
scarier change, but would stop similar problems with other tests (I 
have a feeling that test_pkgimport appears to be leaking 
references because of a different incarnation of the same 
problem).

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=808596&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to