[Spice-devel] [bug spice-gtk] spice-gtk memory leak

xufango xufango at gmail.com
Fri Apr 27 23:20:24 PDT 2012


Finally, I found the memory leak place.

I use valgrind memleak tool:

valgrind --log-file=vg.out --tool=memcheck --leak-check=full -show-reachable=yes --leak-resolution=high 

==14112== 84,144,528 bytes in 237 blocks are definitely lost in loss record 8,054 of 8,056
==14112==    at 0x4A054B6: malloc (vg_replace_malloc.c:236)
==14112==    by 0x364BC471BA: stream_mjpeg_data (channel-display-mjpeg.c:74)
==14112==    by 0x364BC45B61: display_stream_render (channel-display.c:967)
==14112==    by 0x3B2BE3961A: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==14112==    by 0x3B2BE38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)
==14112==    by 0x3B2BE3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)
==14112==    by 0x3B2BE3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)
==14112==    by 0x3AE474C2C6: gtk_main (in /usr/lib64/libgtk-x11-2.0.so.0.1800.9)
==14112==    by 0x40145A: main (main.c:215)

The log showed that nearly 84M memory leaks, it's not small.

I have tried to fix it in destroy_stream() , 
add two lines of code, Am I right?

if (NULL != st->out_frame)
free(st->out_frame); 

// channel-display.c
static void destroy_stream(SpiceChannel *channel, int id)
{
    SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
    display_stream *st;

    g_return_if_fail(c != NULL);
    g_return_if_fail(c->streams != NULL);

    st = c->streams[id];
    if (!st)
        return;

    switch (st->codec) {
    case SPICE_VIDEO_CODEC_TYPE_MJPEG:
        stream_mjpeg_cleanup(st);
        break;
    }

    if (st->msg_clip)
        spice_msg_in_unref(st->msg_clip);
    spice_msg_in_unref(st->msg_create);

    g_queue_foreach(st->msgq, _msg_in_unref_func, NULL);
    g_queue_free(st->msgq);
    if (st->timeout != 0)
        g_source_remove(st->timeout);
  if (NULL != st->out_frame)
free(st->out_frame);  
    free(st);
    c->streams[id] = NULL;
}

Thanks!




xufango

From: Yonit Halperin
Date: 2012-03-19 16:43
To: Marc-André Lureau; Marian Krcmarik
CC: spice-devel
Subject: Re: [Spice-devel] [bug spice-gtk] spice-gtk memory leak
On 03/16/2012 08:13 PM, Marc-André Lureau wrote:
>
>
> ----- Mensaje original -----
>>> Also, running spicy under valgrind leak check tool shows quite
>>> clearly
>>> that there is nothing being leaked directly from spice-gtk, it
>>> seems.
>> As I told you off-line, It happened to me that remote-viewer
>> (spice-gtk client) ended up in 1.3GB, Unfortunately I am not able to
>> reproduce but I am getting 400-500MB and massif does not show
>> anything to me :-/.
>
> Well, if you get 400Mb of resident memory, I would really like to see the massif profile, please send it!
> I couldn't get it above 350Mb here, from which>150Mb were image cache

Hi,

The default size of the cache is 80MB (20 Mega pixels). It shouldn't 
have reached >150MB. I've tracked the add/remove events from the cache, 
and it looks stable around 20 Mega pixels.
I don't manage to get more than 150MB resident memory for the remote-viewer.
Marian, can you describe how you manage to reach more the 400MB? 
Multiple monitors? How long was the remote viewer alive? What guest 
operations did you do? Does it happen if on the qemu side you set 
image-compression=quic (instead of auto-glz)?

Thanks,
Yonit.





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

_______________________________________________
Spice-devel mailing list
Spice-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120428/4b064b3e/attachment.html>


More information about the Spice-devel mailing list