<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
        LINE-HEIGHT: 1.5; FONT-FAMILY: 微软雅黑; COLOR: #000080; FONT-SIZE: 10.5pt
}
</STYLE>
<META name=GENERATOR content="MSHTML 9.00.8112.16443"></HEAD>
<BODY style="MARGIN: 10px">
<DIV style="COLOR: #000000">Finally, I found the memory leak place.</DIV>
<DIV style="COLOR: #000000"> </DIV>
<DIV style="COLOR: #000000">I use valgrind memleak tool:</DIV>
<DIV style="COLOR: #000000"> </DIV>
<DIV
style="COLOR: #000000">valgrind --log-file=vg.out --tool=memcheck --leak-check=full -show-reachable=yes --leak-resolution=high
</DIV>
<DIV style="COLOR: #000000"> </DIV>
<DIV>
<DIV
style="COLOR: #000000">==14112== 84,144,528 bytes in 237 blocks are definitely lost in loss record 8,054 of 8,056</DIV>
<DIV
style="COLOR: #000000">==14112== at 0x4A054B6: malloc (vg_replace_malloc.c:236)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x364BC471BA: stream_mjpeg_data (channel-display-mjpeg.c:74)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x364BC45B61: display_stream_render (channel-display.c:967)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x3B2BE3961A: ??? (in /lib64/libglib-2.0.so.0.2200.5)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x3B2BE38F0D: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2200.5)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x3B2BE3C937: ??? (in /lib64/libglib-2.0.so.0.2200.5)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x3B2BE3CD54: g_main_loop_run (in /lib64/libglib-2.0.so.0.2200.5)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x3AE474C2C6: gtk_main (in /usr/lib64/libgtk-x11-2.0.so.0.1800.9)</DIV>
<DIV
style="COLOR: #000000">==14112== by 0x40145A: main (main.c:215)</DIV></DIV>
<DIV> </DIV>
<DIV style="COLOR: #000000">The log showed that nearly 84M memory leaks, it's
not small.</DIV>
<DIV style="COLOR: #000000"> </DIV>
<DIV style="COLOR: #000000">I have tried to fix it in destroy_stream() , </DIV>
<DIV style="COLOR: #000000">add two lines of code, Am I right?</DIV>
<DIV style="COLOR: #000000"> </DIV>
<DIV style="COLOR: #000000">
<DIV style="COLOR: #ff0000; FONT-SIZE: 10.5pt; FONT-WEIGHT: normal">if (NULL !=
st->out_frame)</DIV>
<DIV
style="TEXT-INDENT: 2em; COLOR: #ff0000; FONT-SIZE: 10.5pt; FONT-WEIGHT: normal">free(st->out_frame);
</DIV></DIV>
<DIV> </DIV>
<DIV>// channel-display.c</DIV>
<DIV>
<DIV>static void destroy_stream(SpiceChannel *channel, int id)</DIV>
<DIV>{</DIV>
<DIV> SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;</DIV>
<DIV> display_stream *st;</DIV>
<DIV> </DIV>
<DIV> g_return_if_fail(c != NULL);</DIV>
<DIV> g_return_if_fail(c->streams != NULL);</DIV>
<DIV> </DIV>
<DIV> st = c->streams[id];</DIV>
<DIV> if (!st)</DIV>
<DIV> return;</DIV>
<DIV> </DIV>
<DIV> switch (st->codec) {</DIV>
<DIV> case SPICE_VIDEO_CODEC_TYPE_MJPEG:</DIV>
<DIV> stream_mjpeg_cleanup(st);</DIV>
<DIV> break;</DIV>
<DIV> }</DIV>
<DIV> </DIV>
<DIV> if (st->msg_clip)</DIV>
<DIV> spice_msg_in_unref(st->msg_clip);</DIV>
<DIV> spice_msg_in_unref(st->msg_create);</DIV>
<DIV> </DIV>
<DIV> g_queue_foreach(st->msgq, _msg_in_unref_func, NULL);</DIV>
<DIV> g_queue_free(st->msgq);</DIV>
<DIV> if (st->timeout != 0)</DIV>
<DIV> g_source_remove(st->timeout);</DIV>
<DIV style="COLOR: #ff0000; FONT-SIZE: 18pt; FONT-WEIGHT: bold"> if
(NULL != st->out_frame)</DIV>
<DIV
style="TEXT-INDENT: 2em; COLOR: #ff0000; FONT-SIZE: 18pt; FONT-WEIGHT: bold">free(st->out_frame);
</DIV>
<DIV> free(st);</DIV>
<DIV> c->streams[id] = NULL;</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>Thanks!</DIV>
<DIV> </DIV></DIV>
<HR style="WIDTH: 210px; HEIGHT: 1px" align=left color=#b5c4df SIZE=1>
<DIV><SPAN>xufango</SPAN></DIV>
<DIV> </DIV>
<DIV
style="BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 0cm; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<DIV
style="PADDING-BOTTOM: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px; BACKGROUND: #efefef; COLOR: #000000; FONT-SIZE: 12px; PADDING-TOP: 8px">
<DIV><B>From:</B> <A href="mailto:yhalperi@redhat.com">Yonit
Halperin</A></DIV>
<DIV><B>Date:</B> 2012-03-19 16:43</DIV>
<DIV><B>To:</B> <A href="mailto:mlureau@redhat.com">Marc-André Lureau</A>;
<A href="mailto:mkrcmari@redhat.com">Marian Krcmarik</A></DIV>
<DIV><B>CC:</B> <A
href="mailto:spice-devel@lists.freedesktop.org">spice-devel</A></DIV>
<DIV><B>Subject:</B> Re: [Spice-devel] [bug spice-gtk] spice-gtk memory
leak</DIV></DIV></DIV>
<DIV>
<DIV>On 03/16/2012 08:13 PM, Marc-André Lureau wrote:</DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>> ----- Mensaje original -----</DIV>
<DIV>>>> Also, running spicy under valgrind leak check tool shows quite</DIV>
<DIV>>>> clearly</DIV>
<DIV>>>> that there is nothing being leaked directly from spice-gtk, it</DIV>
<DIV>>>> seems.</DIV>
<DIV>>> As I told you off-line, It happened to me that remote-viewer</DIV>
<DIV>>> (spice-gtk client) ended up in 1.3GB, Unfortunately I am not able to</DIV>
<DIV>>> reproduce but I am getting 400-500MB and massif does not show</DIV>
<DIV>>> anything to me :-/.</DIV>
<DIV>></DIV>
<DIV>> Well, if you get 400Mb of resident memory, I would really like to see the massif profile, please send it!</DIV>
<DIV>> I couldn't get it above 350Mb here, from which>150Mb were image cache</DIV>
<DIV> </DIV>
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>The default size of the cache is 80MB (20 Mega pixels). It shouldn't </DIV>
<DIV>have reached >150MB. I've tracked the add/remove events from the cache, </DIV>
<DIV>and it looks stable around 20 Mega pixels.</DIV>
<DIV>I don't manage to get more than 150MB resident memory for the remote-viewer.</DIV>
<DIV>Marian, can you describe how you manage to reach more the 400MB? </DIV>
<DIV>Multiple monitors? How long was the remote viewer alive? What guest </DIV>
<DIV>operations did you do? Does it happen if on the qemu side you set </DIV>
<DIV>image-compression=quic (instead of auto-glz)?</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV>Yonit.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>> _______________________________________________</DIV>
<DIV>> Spice-devel mailing list</DIV>
<DIV>> Spice-devel@lists.freedesktop.org</DIV>
<DIV>> http://lists.freedesktop.org/mailman/listinfo/spice-devel</DIV>
<DIV> </DIV>
<DIV>_______________________________________________</DIV>
<DIV>Spice-devel mailing list</DIV>
<DIV>Spice-devel@lists.freedesktop.org</DIV>
<DIV>http://lists.freedesktop.org/mailman/listinfo/spice-devel</DIV></DIV></BODY></HTML>