Bug#816872: wmbattery: memory leak in wmbattery

David Johnson davijoh3 at cisco.com
Mon Oct 23 20:49:30 UTC 2017


Doug,

When I first filed this bug I did some digging with valgrind trying to
find the leaks.

I found several issues with the upower module (the older methonds were
less leaky).  valgrind found lots of leaks, but they were hard to
trace, except that most/all were in the upower area.  I suspect that
some of the leaks are in libupower not wmbattery, however it wasn't
clear to me if it was wmbattery's usage of libupower or libupower
itself.

I did find the following improved the leaks, however it was still
leaking, just not as bad.

Also the rate of leaks is directly linked to the "-w" option, the
faster the refresh the faster the leaking.


Hope this helps:

diff -Nuar wmbattery-2.50.orig/upower.c wmbattery-2.50/upower.c
--- wmbattery-2.50.orig/upower.c        2015-08-30 19:58:13.000000000 -0400
+++ wmbattery-2.50/upower.c     2016-03-20 16:08:57.177709309 -0400
@@ -78,8 +78,6 @@
        GPtrArray *devices = NULL;
        static int retries = 0;
 
-       up = up_client_new();
-
        if (!up)
                return -1;
 
@@ -143,6 +141,6 @@
                info->battery_status = BATTERY_STATUS_ABSENT;
        }
 
-       g_ptr_array_free(devices, TRUE);
+       g_ptr_array_unref(devices);
        return 0;
 }




-- 
David Johnson
Principal Engineer



More information about the Pkg-wmaker-devel mailing list