Subject: Re: bug#75636: GTK memory leaks

From: Pip Cet <[email-masked]>
Date: Sat, 18 Jan 2025 11:49:58 +0000

"Po Lu" <[email-masked]> writes:

> Pip Cet <[email-masked]> writes:
>
>> 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.
>
> Strange, I was under the impression that IM contexts descended from
> GInitiallyUnowned.  Evidently they don't, and as such, removing the
> g_object_ref will suffice.

Thanks!  I'll just do that, then?  I think it's okay only to do it on
master, as it's a minor bug in the !HAVE_MPS case.

>> 2. free_frame_tool_bar is never called in my experiments, so the toolbar
>> widget isn't destroyed.
>
> It is only supposed to be called when a frame's tool bar is disabled.
> while it is x_free_frame_resources that should release all resources
> when a frame is to be destroyed.

Thanks!  I'll come up with a patch and discuss it further for this one,
because it's not quite trivial.

Pip