bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35179: [PATCH] Plug memory leak in GTK x-display-monitor-attributes-


From: Alex
Subject: bug#35179: [PATCH] Plug memory leak in GTK x-display-monitor-attributes-list
Date: Sun, 07 Apr 2019 08:51:12 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

> But I have a more fundamental problem with your proposed patch: it looks like
> you are relying on implementation details of gdk_monitor_get_model that its
> documentation never advertises? Otherwise, how did you know that just removing
> the g_strdup call will plug a memory leak here, and will not create any new
> problems?
>
> I'd prefer to leave g_strdup intact, and instead explicitly release the 
> storage of previous value.  IOW, plug the leak in our own code, not rely on 
> undocumented features which can easily go away some day.

The documentation of gdk_monitor_get_model[1] specifies that the return
value is "[transfer none]", which has the description "Don't free data
after code is done".

The main memory leak, though, was that the MonitorList array wasn't
being freed. I considered using the free_monitors procedure like the
non-GTK versions do, but I saw no reason to call g_strdup for each name
and free each name almost right after.

Since make_monitor_attribute_list uses make_string on each name, I don't
see any issues that this removal would cause.


[1] 
https://developer.gnome.org/gdk3/stable/GdkMonitor.html#gdk-monitor-get-model





reply via email to

[Prev in Thread] Current Thread [Next in Thread]