<html>
    <head>
      <base href="https://bugzilla.gnome.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - memory leak"
   href="https://bugzilla.gnome.org/show_bug.cgi?id=761312#c53">Comment # 53</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - memory leak"
   href="https://bugzilla.gnome.org/show_bug.cgi?id=761312">bug 761312</a>
              from <span class="vcard"><a href="page.cgi?id=describeuser.html&login=jadahl%40gmail.com" title="Jonas Ådahl <jadahl@gmail.com>"> <span class="fn">Jonas Ådahl</span></a>
</span></b>
        <pre>Review of <span class=""><a href="attachment.cgi?id=320366&action=diff" name="attach_320366" title="wayland: stage uncommitted changes to dedicated buffer">attachment 320366</a> <a href="attachment.cgi?id=320366&action=edit" title="wayland: stage uncommitted changes to dedicated buffer">[details]</a></span> <a href='review?bug=761312&attachment=320366'>[review]</a>:

::: gdk/wayland/gdkwindow-wayland.c
@@ +671,3 @@
+   * the old committed buffer again.
+   */
+  impl->staging_cairo_surface = g_steal_pointer
(&impl->committed_cairo_surface);

Looks like we'll leak GdkWindowImplWayland and the released buffer here if the
window was already destroyed before wl_buffer.release was received. The
triggering flow:

1. draw into and attach+commit wl_buffer@123 (committed = wl_buffer@123,
staging == NULL, window ref = 2)
2. destroy window (window ref = 1, last ref held by wl_buffer@123, committed =
wl_buffer@123)
3. <a href="mailto:wl_buffer@123.release">wl_buffer@123.release</a> (committed = NULL, staging = wl_buffer@123, window_ref
= 1)

What is the benefit of not just detaching buffers/cairo-surfaces on window
destruction? We'd leak them either way if we disconnect from the server since
we won't get any release events, and to fix that we need a per display
connection list of cairo surfaces that needs to be explicitly destroyed on
disconnect, and having a circular reference (impl -> cairo surface -> impl)
doesn't seem to help with that.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>