After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 670307 - [PATCH] Unown the bus name to release some memory
[PATCH] Unown the bus name to release some memory
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2012-02-17 17:33 UTC by Daniel Trebbien
Modified: 2012-02-18 10:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix (2.23 KB, patch)
2012-02-17 17:38 UTC, Daniel Trebbien
needs-work Details | Review
Fix (2.26 KB, patch)
2012-02-17 22:05 UTC, Daniel Trebbien
committed Details | Review

Description Daniel Trebbien 2012-02-17 17:33:35 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
}
Comment 1 Daniel Trebbien 2012-02-17 17:38:32 UTC
Created attachment 207870 [details] [review]
Fix
Comment 2 Ignacio Casal Quinteiro (nacho) 2012-02-17 22:00:51 UTC
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
Comment 3 Daniel Trebbien 2012-02-17 22:05:20 UTC
Created attachment 207906 [details] [review]
Fix
Comment 4 Ignacio Casal Quinteiro (nacho) 2012-02-18 10:04:59 UTC
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.
Comment 5 Ignacio Casal Quinteiro (nacho) 2012-02-18 10:05:25 UTC
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.