[Python-bugs-list] [ python-Bugs-456504 ] Memory leak in PyString_FromString
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 18 Oct 2001 12:46:09 -0700
Bugs item #456504, was opened at 2001-08-29 06:09
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=456504&group_id=5470
Category: Python Interpreter Core
>Group: Irreproducible
>Status: Closed
>Resolution: Invalid
Priority: 4
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Barry Warsaw (bwarsaw)
Summary: Memory leak in PyString_FromString
Initial Comment:
Purify (on WinNT) reports a memory leak:
Memory leak of 567 bytes from 14 blocks allocated in
PyString_FromString
Distribution of leaked blocks
Allocation location
malloc [msvcrt.dll]
PyString_FromString [python21.dll]
??? [python.exe ip=0x00405059]
This fragments the heap and my long-running program
eventually runs out of memory. I was running my sample
program with wxPython and so could not run debug
version for more explicit info without compiling wx
myself. If this is not enough info we can probably get
a more detailed output.
----------------------------------------------------------------------
>Comment By: Barry Warsaw (bwarsaw)
Date: 2001-10-18 12:46
Message:
Logged In: YES
user_id=12800
Closing as per Guido's recommendation.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-05 10:51
Message:
Logged In: YES
user_id=6380
With 99.9% probability, this is not a bug in
PyString_FromString(), but a missing Py_DECREF() somewhere
else. Because of the way reference counting works, missing
DECREFs show up as memory leaks originating in one of the
"new-object-creation" routines, but these routines are
usually without blame.
The trick is to find the missing DECREF! If you want to help
us fund it, the best thing to do is boil your example
program down to something as small as possible that still
exhibits the leak -- then show us the code. With the Python
code in hand we can look at what C code is being invoked
that might have a missing DECREF. I've done this many times
so I know it can be very effective -- and Purify or Insure
are very little help, alas.
HOWEVER, you mention wxPython. That's a HUGE body of 3rd
party code. If you can only reproduce this when wxPython is
involved, it's probably a bug in wxPython (3rd party code is
always the most likely cause for refcount bugs, in my
experience).
I propose to lower the priority and close this bug a month
from now if no new evidence is found that it's a core Python
bug.
(BTW the Python version would also be handy to know.)
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-08-29 12:40
Message:
Logged In: YES
user_id=31435
I'm afraid we need better evidence of a "real leak" than
this. PyString_FromString is called from 100s of
locations, and some of the targets are file-static vrbls
that indeed are never *expected* to get cleared (for
example, abstract.c constructs the string "__bases__" once
and then reuses it forever after).
BTW, it's extremely unlikely that a "loss" of 567 bytes is
causing you to run out of memory, yes? I'd look elsewhere.
Assigning to Barry, since he runs Insure++ regularly.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=456504&group_id=5470