This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Python] Patch to fix memory leak
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Paul Koning <paulkoning at comcast dot net>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 07 Sep 2011 10:27:24 +0100
- Subject: Re: [Python] Patch to fix memory leak
- References: <9E006B29-53D6-475E-9024-E1E9933A99C6@comcast.net>
- Reply-to: pmuldoon at redhat dot com
Paul Koning <paulkoning@comcast.net> writes:
> PyList_Append increments the reference count of the item being
> appended to the list, and two of the places in the GDB Python code
> that use it don't take that into account. The result is a memory
> leak. The attached patch fixes that.
For some reason the Python API manual is silent about PyList_Append
incrementing the reference count. But I did check, and you are correct,
the reference count is incremented when added to a list.
> Tested by using a debug build of Python with reference counting
> enabled, and turning on dumping of final leftover objects.
This is fine, thanks for doing this. I cannot give you check-in
permission as I am not a maintainer. Please wait until one of the
maintainers signs-off before you go ahead.
Cheers,
Phil