[Spice-devel] spice-gtk / remote viewer leaks (gobs of) memory - possibly related to animated mouse cursor?

Marc-André Lureau mlureau at redhat.com
Tue May 6 08:12:04 PDT 2014



----- Original Message -----
> Hi
> 
> ----- Original Message -----
> > 
> > On 05/06/2014 09:49 AM, David Mansfield wrote:
> > >
> > > On 05/06/2014 06:04 AM, Marc-André Lureau wrote:
> > >> Hi
> > >>
> > >> ----- Original Message -----
> > >>> On 05/05/2014 04:10 PM, Marc-André Lureau wrote:
> > >>>> Hi
> > >>>>
> > >>>> ----- Original Message -----
> > >>>>> Any way to easily trace memory leaks in remote-viewer?  A naive
> > >>>>> attempt
> > >>>>> at "valgrind remote-viewer spice://blah" didn't turn up anything in
> > >>>>> particular.
> > >>>> Have you tried with massif? It usually gives pretty good hints.
> > >>> Here is "ms_print" output. I've never used massif before, is this
> > >>> helpful?
> > >> This massif profile doesn't show a large memory usage or any obvious
> > >> leak.
> > >>
> > >> Are you looking at virtual or resident (RSS) memory usage? (remember
> > >> that
> > >> only RSS really "count")
> > > Yes, RSS goes over 2GB easily with 8 hours of usage.
> > >
> > > I have changed spice-widget.c as follows:
> > >
> > > @@ -2205,14 +2210,15 @@
> > > (GdkPixbufDestroyNotify)g_free, NULL);
> > >          d->mouse_hotspot.x = hot_x;
> > >          d->mouse_hotspot.y = hot_y;
> > > -        cursor =
> > > gdk_cursor_new_from_pixbuf(gtk_widget_get_display(GTK_WIDGET(display)),
> > > -                                            d->mouse_pixbuf, hot_x,
> > > hot_y);
> > > +        cursor =
> > > gdk_cursor_new_for_display(gtk_widget_get_display(GTK_WIDGET(display)),
> > > GDK_FLEUR);
> > >
> > > +        //cursor =
> > > gdk_cursor_new_from_pixbuf(gtk_widget_get_display(GTK_WIDGET(display)),
> > > +        //                                   d->mouse_pixbuf, hot_x,
> > > hot_y);
> > >      } else
> > >          g_warn_if_reached();
> > >
> > >
> > > And, while it's true I only get a hand cursor no matter what, there is
> > > no leak.  I can wiggle the mouse to my heart's content and the RSS
> > > stays flat (after initially increasing to fill the local tile cache).
> > > There is 100% no doubt in my mind that there is a leak here.  Although
> > > the code looks correct to me.
> > >
> > > I also tried changing gdk_cursor_unref to g_object_unref but it made
> > > no difference.
> > 
> > I'm certainly not familiar with gtk3/gdk internals, but it seems like
> > gdk/gdkcursor.c (in function gdk_cursor_new_from_pixbuf, line 385 in
> > F20) allocates a "cairo surface" for each cursor that is created from
> > pixbuf that is leaked.
> > 
> > Any gdk gurus on the list to check this?
> 
> I come to the same conclusion as you, it seems cairo will add a ref to the
> surface in
> 
> _gdk_x11_display_get_cursor_for_surface
>   create_cursor_image
>     cairo_set_source_surface (cr, source_surface, 0, 0);
> 
> So a cairo_surface_destroy() seems to be missing there. Could you try with
> that?
> 
> Funny that we don't see that leak in your massif profile.

Actually, it is there, in last snapshot for ex, 30Mb of cursor data in memory (!):

->12.38% (18,381,168B) 0x35164A285E: ??? (in /usr/lib64/libcairo.so.2.11301.0)
| ->12.38% (18,381,168B) 0x35164A33E5: ??? (in /usr/lib64/libcairo.so.2.11301.0)
| | ->12.38% (18,381,168B) 0x35164A347A: ??? (in /usr/lib64/libcairo.so.2.11301.0)
| | | ->12.38% (18,381,168B) 0x351647083B: cairo_surface_create_similar_image (in /usr/lib64/libcairo.so.2.11301.0)
| | |   ->12.38% (18,381,168B) 0x351783E5BF: gdk_window_create_similar_image_surface (in /usr/lib64/libgdk-3.so.0.1000.8)
| | |   | ->12.38% (18,381,168B) 0x3517821404: gdk_cairo_surface_create_from_pixbuf (in /usr/lib64/libgdk-3.so.0.1000.8)
| | |   |   ->12.38% (18,377,280B) 0x3517822185: gdk_cursor_new_from_pixbuf (in /usr/lib64/libgdk-3.so.0.1000.8)
| | |   |   | ->12.38% (18,377,280B) 0x374B80E1A1: cursor_set (spice-widget.c:2213)
| | |   |   |   ->12.38% (18,377,280B) 0x37490464A0: g_cclosure_user_marshal_VOID__INT_INT_INT_INT_POINTER (spice-marshal.c:204)
| | |   |   |     ->12.38% (18,377,280B) 0x3BD7E10296: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | |   |   |       ->12.38% (18,377,280B) 0x3BD7E2235B: ??? (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | |   |   |         ->12.38% (18,377,280B) 0x3BD7E2A0F0: g_signal_emit_valist (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | |   |   |           ->12.38% (18,377,280B) 0x3BD7E2A3AD: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | |   |   |             ->12.38% (18,377,280B) 0x3749021C8A: do_emit_main_context (channel-cursor.c:233)
| | |   |   |               ->12.38% (18,377,280B) 0x3749020B9F: emit_main_context (gio-coroutine.c:199)
| | |   |   |                 ->12.38% (18,377,280B) 0x3BD72492A4: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
| | |   |   |                   ->12.38% (18,377,280B) 0x3BD7249626: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
| | |   |   |                     ->12.38% (18,377,280B) 0x3BD7249A38: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
| | |   |   |                       ->12.38% (18,377,280B) 0x35171AA693: gtk_main (in /usr/lib64/libgtk-3.so.0.1000.8)
| | |   |   |                         ->12.38% (18,377,280B) 0x40EF49: main (in /usr/bin/remote-viewer)
| | |   |   |                           
| | |   |   ->00.00% (3,888B) in 1+ places, all below ms_print's threshold (01.00%)
| | |   |   
| | |   ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
| | |   
| | ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
| | 
| ->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
| 
->07.49% (11,118,848B) 0x3BE1E58649: ??? (in /usr/lib64/libpixman-1.so.0.30.0)
| ->07.49% (11,118,848B) 0x3BE1E23A28: ??? (in /usr/lib64/libpixman-1.so.0.30.0)
| | ->07.33% (10,892,544B) 0x35164A2A8F: ??? (in /usr/lib64/libcairo.so.2.11301.0)
| | | ->07.33% (10,892,544B) 0x35164A33E5: ??? (in /usr/lib64/libcairo.so.2.11301.0)
| | | | ->07.33% (10,892,544B) 0x35164A347A: ??? (in /usr/lib64/libcairo.so.2.11301.0)
| | | | | ->07.33% (10,892,544B) 0x351647083B: cairo_surface_create_similar_image (in /usr/lib64/libcairo.so.2.11301.0)
| | | | |   ->07.33% (10,892,544B) 0x351783E5BF: gdk_window_create_similar_image_surface (in /usr/lib64/libgdk-3.so.0.1000.8)
| | | | |   | ->07.33% (10,892,544B) 0x3517821404: gdk_cairo_surface_create_from_pixbuf (in /usr/lib64/libgdk-3.so.0.1000.8)
| | | | |   |   ->07.33% (10,890,240B) 0x3517822185: gdk_cursor_new_from_pixbuf (in /usr/lib64/libgdk-3.so.0.1000.8)
| | | | |   |   | ->07.33% (10,890,240B) 0x374B80E1A1: cursor_set (spice-widget.c:2213)
| | | | |   |   |   ->07.33% (10,890,240B) 0x37490464A0: g_cclosure_user_marshal_VOID__INT_INT_INT_INT_POINTER (spice-marshal.c:204)
| | | | |   |   |     ->07.33% (10,890,240B) 0x3BD7E10296: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | | | |   |   |       ->07.33% (10,890,240B) 0x3BD7E2235B: ??? (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | | | |   |   |         ->07.33% (10,890,240B) 0x3BD7E2A0F0: g_signal_emit_valist (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | | | |   |   |           ->07.33% (10,890,240B) 0x3BD7E2A3AD: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.3800.2)
| | | | |   |   |             ->07.33% (10,890,240B) 0x3749021C8A: do_emit_main_context (channel-cursor.c:233)
| | | | |   |   |               ->07.33% (10,890,240B) 0x3749020B9F: emit_main_context (gio-coroutine.c:199)
| | | | |   |   |                 ->07.33% (10,890,240B) 0x3BD72492A4: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.3800.2)
| | | | |   |   |                   ->07.33% (10,890,240B) 0x3BD7249626: ??? (in /usr/lib64/libglib-2.0.so.0.3800.2)
| | | | |   |   |                     ->07.33% (10,890,240B) 0x3BD7249A38: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.3800.2)
| | | | |   |   |                       ->07.33% (10,890,240B) 0x35171AA693: gtk_main (in /usr/lib64/libgtk-3.so.0.1000.8)
| | | | |   |   |                         ->07.33% (10,890,240B) 0x40EF49: main (in /usr/bin/remote-viewer)
| | | | |   |   |                           
| | | | |   |   ->00.00% (2,304B) in 1+ places, all below ms_print's threshold (01.00%)

> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list