[patch] python-dbus 0.80.1 memory leak issue

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Jan 31 05:53:01 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 30 Jan 2007 at 23:42:53 +0100, Luka Renko wrote:
> I am one of the developers of KDE Guidance Power Manager that uses python-dbus 
> to access HAL for power management (battery, suspend/hibernate, CPU freq 
> scaling). By recent upgrade of python-dbus in Kubuntu Feisty to python-dbus 
> 0.80.1 we have got several user complaints about huge memory consumption of 
> our application. Memory was used in the range of 0.5 MB/minute. See bug [1] 
> for more details.

The patch below should fix that. J5: review please? If you approve, I'll do
a 0.80.2 release with this change.

Also available in <http://people.freedesktop.org/~smcv/git/dbus-python/.git>

	Simon

- From 99e0758b1d4f958e5753d51e843f1254e15b93b2 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Wed, 31 Jan 2007 13:47:49 +0000
Subject: [PATCH] _dbus_bindings/pending-call.c: Fix memory leak of one Message per method call.
Also fix a leak of references to Py_None (unlikely to be a practical problem,
but best to be correct).
- ---
 _dbus_bindings/pending-call.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/_dbus_bindings/pending-call.c b/_dbus_bindings/pending-call.c
index b9b7bc1..73071c3 100644
- --- a/_dbus_bindings/pending-call.c
+++ b/_dbus_bindings/pending-call.c
@@ -111,13 +111,14 @@ _pending_call_notify_function(DBusPendingCall *pc,
                 PyErr_Print();
             }
             Py_XDECREF(ret);
+            Py_DECREF(msg_obj);
         }
         /* else OOM has happened - not a lot we can do about that,
          * except possibly making it fatal (FIXME?) */
     }
 
- -    Py_XDECREF(handler);
 release:
+    Py_XDECREF(handler);
     PyGILState_Release(gil);
 }
 
@@ -161,7 +162,7 @@ DBusPyPendingCall_ConsumeDBusPendingCall(DBusPendingCall *pc,
     PyList_SET_ITEM(list, 0, callable);
 
     /* INCREF so we can give a ref to set_notify and still have one */
- -    Py_INCREF(list);    
+    Py_INCREF(list);
 
     Py_BEGIN_ALLOW_THREADS
     ret = dbus_pending_call_set_notify(pc,
- -- 
1.4.4.4

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: OpenPGP key: http://www.pseudorandom.co.uk/2003/contact/ or pgp.net

iD8DBQFFwJ89WSc8zVUw7HYRAqmsAKCm+/sfWDWB77xKPGGL+ab5gfB1gQCgia9k
wpDRRvw2dFbzuEoAwa4msOE=
=XaIj
-----END PGP SIGNATURE-----


More information about the dbus mailing list