GNU bug report logs - #75636
GTK memory leaks

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> protonmail.com>

Date: Fri, 17 Jan 2025 20:16:01 UTC

Severity: normal

Done: Pip Cet <pipcet <at> protonmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Pip Cet <pipcet <at> protonmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#75636: closed (GTK memory leaks)
Date: Sat, 01 Feb 2025 23:32:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 01 Feb 2025 23:31:19 +0000
with message-id <87o6zl9r9v.fsf <at> protonmail.com>
and subject line Re: bug#75636: GTK memory leaks
has caused the debbugs.gnu.org bug report #75636,
regarding GTK memory leaks
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
75636: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75636
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Pip Cet <pipcet <at> protonmail.com>
To: bug-gnu-emacs <at> gnu.org, Po Lu <luangruo <at> yahoo.com>
Subject: GTK memory leaks
Date: Fri, 17 Jan 2025 20:15:02 +0000
Creating and destroying GTK frames (using gtkutil.c, not PGTK) currently
leaks some memory, particularly when using tool bars.

1. The input "multicontext" created by:

  imc = gtk_im_multicontext_new ();
  g_object_ref (imc);

is only unref'd once when destroying the frame.  This leaves the
refcount at 1 and leaks the object.

2. free_frame_tool_bar is never called in my experiments, so the toolbar
widget isn't destroyed.

This isn't usually a problem because it's just a small memory leak, but
on the feature/igc branch, user data passed to glib must be protected in
a special GC root structure; such structures accumulate when running in
GTK, eventually reducing GC performance significantly.

Unfortunately, valgrind doesn't seem to catch these memory leaks.



[Message part 3 (message/rfc822, inline)]
From: Pip Cet <pipcet <at> protonmail.com>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 75636-done <at> debbugs.gnu.org
Subject: Re: bug#75636: GTK memory leaks
Date: Sat, 01 Feb 2025 23:31:19 +0000
Pip Cet <pipcet <at> protonmail.com> writes:

> "Po Lu" <luangruo <at> yahoo.com> writes:
>
>>> commit 5ed4aaa986dbf75f8565f4d8cdd3d1d1b38b6142 (HEAD)
>>> Author: Pip Cet <pipcet <at> protonmail.com>
>>>
>>>     Destroy GTK tool bar widget if it was never attached (bug#75636)
>>>
>>>     * src/gtkutil.c (xg_free_frame_widgets): Call gtk_widget_destroy on an
>>>     unpacked toolbar widget.
>>>
>>> diff --git a/src/gtkutil.c b/src/gtkutil.c
>>> index 0e9dd4dfe11..97582a524da 100644
>>> --- a/src/gtkutil.c
>>> +++ b/src/gtkutil.c
>>> @@ -1885,6 +1885,12 @@ xg_free_frame_widgets (struct frame *f)
>>>        if (tbinfo)
>>>          xfree (tbinfo);
>>>
>>> +      if (x->toolbar_widget && !x->toolbar_is_packed)
>>> +	{
>>> +	  gtk_widget_destroy (x->toolbar_widget);
>>> +	  x->toolbar_widget = NULL;
>>> +	}
>>> +
>>>        /* x_free_frame_resources should have taken care of it */
>>>  #ifndef HAVE_PGTK
>>>  #ifdef HAVE_XDBE
>>
>> LGTM.
>
> Thanks, pushed.

While GTK remains very slow due to MPS limitations and the way we work
around them, I'll file a new bug when we have a way around that, and
closing this one.  Thanks!

Pip



This bug report was last modified 166 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.