GNOME Bugzilla – Bug 670307
[PATCH] Unown the bus name to release some memory
Last modified: 2012-02-18 10:05:25 UTC
g_bus_unown_name() should be called to unown the bus name that is obtained by gedit_dbus_run(). With the attached patch, Valgrid's log no longer includes these entries: ==8658== 16 bytes in 1 blocks are still reachable in loss record 1,449 of 11,871 ==8658== at 0x4C2A4CD: malloc (vg_replace_malloc.c:236) ==8658== by 0x87972F7: standard_malloc (gmem.c:85) ==8658== by 0x8797380: g_malloc (gmem.c:159) ==8658== by 0x879765B: g_malloc_n (gmem.c:361) ==8658== by 0x87B1518: g_strdup (gstrfuncs.c:356) ==8658== by 0x75E45F5: g_bus_own_name (gdbusnameowning.c:641) ==8658== by 0x432064: gedit_dbus_run (gedit-dbus.c:1681) ==8658== by 0x427B9D: main (gedit.c:308) ==8658== { <insert_a_suppression_name_here> Memcheck:Leak fun:malloc fun:standard_malloc fun:g_malloc fun:g_malloc_n fun:g_strdup fun:g_bus_own_name fun:gedit_dbus_run fun:main } ==8658== 112 bytes in 1 blocks are still reachable in loss record 10,499 of 11,871 ==8658== at 0x4C28BB4: calloc (vg_replace_malloc.c:467) ==8658== by 0x879735B: standard_calloc (gmem.c:104) ==8658== by 0x87973F7: g_malloc0 (gmem.c:189) ==8658== by 0x87976CF: g_malloc0_n (gmem.c:385) ==8658== by 0x75E45C5: g_bus_own_name (gdbusnameowning.c:638) ==8658== by 0x432064: gedit_dbus_run (gedit-dbus.c:1681) ==8658== by 0x427B9D: main (gedit.c:308) ==8658== { <insert_a_suppression_name_here> Memcheck:Leak fun:calloc fun:standard_calloc fun:g_malloc0 fun:g_malloc0_n fun:g_bus_own_name fun:gedit_dbus_run fun:main }
Created attachment 207870 [details] [review] Fix
Review of attachment 207870 [details] [review]: See the inline comment. ::: gedit/gedit-dbus.c @@ +178,3 @@ + if (dbus->priv->owner_id != 0) + { + g_bus_unown_name (dbus->priv->owner_id); the dispose can run several times, you must set the owner_id to 0 here after unowning the name
Created attachment 207906 [details] [review] Fix
Review of attachment 207906 [details] [review]: Pushed the patch with the minor fix in the inline comment. Thanks a lot for it. ::: gedit/gedit-dbus.c @@ +200,3 @@ self->priv = GEDIT_DBUS_GET_PRIVATE (self); + + self->priv->owner_id = 0; One minor thing that I missed before. This line is not needed. GObject sets all the values of the private struct to 0.
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.