[gtk/wip/otte/for-master: 4/4] wayland: Fix memleaks when rendering with Cairo
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-master: 4/4] wayland: Fix memleaks when rendering with Cairo
- Date: Tue, 9 Mar 2021 18:54:50 +0000 (UTC)
commit 0a9d075b47a06c342ab3fee84c230ba768f05257
Author: Benjamin Otte <otte redhat com>
Date: Tue Mar 9 19:52:59 2021 +0100
wayland: Fix memleaks when rendering with Cairo
We were leaking buffers. This wasn't caught by valgrind and friends
because it was shared memory (with the compositor), but top(1) would
instantly see memory consumption of the app and the shell go through the
roof.
gdk/wayland/gdkcairocontext-wayland.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gdk/wayland/gdkcairocontext-wayland.c b/gdk/wayland/gdkcairocontext-wayland.c
index fcc547ecf6..819daa140e 100644
--- a/gdk/wayland/gdkcairocontext-wayland.c
+++ b/gdk/wayland/gdkcairocontext-wayland.c
@@ -109,6 +109,8 @@ gdk_wayland_cairo_context_buffer_release (void *_data,
/* Get rid of all the extra ones */
gdk_wayland_cairo_context_remove_surface (self, cairo_surface);
+ /* Release the reference the compositor held to this surface */
+ cairo_surface_destroy (cairo_surface);
}
static const struct wl_buffer_listener buffer_listener = {
@@ -194,7 +196,7 @@ gdk_wayland_cairo_context_end_frame (GdkDrawContext *draw_context,
static void
gdk_wayland_cairo_context_clear_all_cairo_surfaces (GdkWaylandCairoContext *self)
{
- self->cached_surface = NULL;
+ g_clear_pointer (&self->cached_surface, cairo_surface_destroy);
while (self->surfaces)
gdk_wayland_cairo_context_remove_surface (self, self->surfaces->data);
}
@@ -221,6 +223,8 @@ gdk_wayland_cairo_context_dispose (GObject *object)
GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (object);
gdk_wayland_cairo_context_clear_all_cairo_surfaces (self);
+ g_assert (self->cached_surface == NULL);
+ g_assert (self->paint_surface == NULL);
G_OBJECT_CLASS (gdk_wayland_cairo_context_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]