Issue808596
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2003-09-18 14:48 by mwh, last changed 2022-04-10 16:11 by admin. This issue is now closed.
Messages (6) | |||
---|---|---|---|
msg18207 - (view) | Author: Michael Hudson (mwh) | Date: 2003-09-18 14:48 | |
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. |
|||
msg18208 - (view) | Author: Michael Hudson (mwh) | Date: 2004-08-02 12:56 | |
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). |
|||
msg18209 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2004-08-02 15:11 | |
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. |
|||
msg18210 - (view) | Author: Michael Hudson (mwh) | Date: 2004-08-03 10:25 | |
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. |
|||
msg18211 - (view) | Author: Michael Hudson (mwh) | Date: 2004-08-09 13:46 | |
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. |
|||
msg18212 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2005-12-19 03:36 | |
Logged In: YES user_id=33168 I just tested this on 2.5a and there were no ref leaks, so closing again. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:11:13 | admin | set | github: 39254 |
2003-09-18 14:48:35 | mwh | create |