[Xcb] XPutImage to a pixmap is leaking memory

Guillaume Foliard guifo at wanadoo.fr
Tue Jun 1 12:33:27 PDT 2010


Hello,

On Tuesday 01 June 2010 16:49:37 Jamey Sharp wrote:
> On Tue, Jun 1, 2010 at 5:34 AM, Guillaume Foliard <guifo at wanadoo.fr> wrote:
> > Here is a rough copy/paste from the Valgrind output :
> > 
> > ==10123== 15,984 bytes in 999 blocks are indirectly lost in loss record
> > 21 of 25 ==10123== at 0x4A0515D: malloc (vg_replace_malloc.c:195)
> > ==10123== by 0x3B3860A6B1: ??? (in /usr/lib64/libxcb.so.1.1.0)
> > ==10123== by 0x3B386088EC: ??? (in /usr/lib64/libxcb.so.1.1.0)
> > ==10123== by 0x3B38608D86: ??? (in /usr/lib64/libxcb.so.1.1.0)
> > ==10123== by 0x3B38609034: xcb_writev (in /usr/lib64/libxcb.so.1.1.0)
> > ==10123== by 0x3B38A4D419: _XSend (in /usr/lib64/libX11.so.6.3.0)
> > ==10123== by 0x3B38A3985C: ??? (in /usr/lib64/libX11.so.6.3.0)
> > ==10123== by 0x3B38A38B50: ??? (in /usr/lib64/libX11.so.6.3.0)
> > ==10123== by 0x3B38A39A3D: XPutImage (in /usr/lib64/libX11.so.6.3.0)
> > ==10123== by 0x400B9D: main (put_image.c:76)
> > 
> > When run on an older Linux distribution without XCB a leak is also
> > observed, but in libX11.
> 
> Why did you comment out the XCloseDisplay call? You'll certainly see
> leak reports in valgrind if you do that, making it hard to tell
> whether this is really a bug.

The call to XCloseDisplay is indeed freeing the memory, if uncommented, the 
"leak" is not displayed anymore in the Valgrind output.
The issue is that I have an application in which XPutImage is called 
repeatedly and which has to run for hours. In the end the accumulation of 
"leaked" memory gets too large for the host system.
So by commenting out the XCloseDisplay call in the small test case I was able 
to discover the origin of the "leak".

> I bet you'll find it doesn't "leak" if you call XNextEvent before the
> program exits. I think you're seeing it read back the Expose event
> from the MapWindow request, which you're then ignoring.
> 
> If this really is a bug, you need to install debug symbols and grab
> that same stack trace from valgrind again. Looks like these
> instructions apply to Fedora:
> 
> http://fedoraproject.org/wiki/StackTraces

I'll try to do that.

> Also, your mail client seems to have mangled your example program.
> Perhaps you should make it an attachment instead.

Here is it attached.

Thank you for your suggestions,

Guillaume
-------------- next part --------------
A non-text attachment was scrubbed...
Name: put_image.c
Type: text/x-csrc
Size: 2356 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20100601/879053cd/attachment.c>


More information about the Xcb mailing list