From: gillett@rice-chex.ai.mit.edu (Walter E. Gillett)
Newsgroups: fj.mail-lists.x-window
Subject: Help: _XEnq() SEEMS to be leaking memory (_XQEvent structs)
Date: 4 Oct 92 21:35:29 GMT
Distribution: fj
Organization: MIT Artificial Intelligence Lab

Date: 2 Oct 92 22:19:31 GMT
Message-Id: <28796@life.ai.mit.edu>
Newsgroups: comp.windows.x.intrinsics,comp.windows.x

Hi, Folks
    I've got a test application that contains a toplevel shell widget and a
custom display-list widget that I wrote.  It's basically a small graphics
package on top of Xlib primitives.

    Anyway, the test program causes the widget to XCopyPlane() lots of bitmaps
into a pixmap.  The GC used in the XCopyPlane() has a clip-mask set.  I'll
include this part of the code at the end of the message.

    When I do lots of these XCopyPlane()'s my process starts eating up _XEQevent
structs allocated with this traceback:
    malloc()
    _XEnq()
    _XWaitForWritable()
    _XFlush()
    _XFlushGCCache()
    XCopyPlane()

    This happens with both MIT X11R4 and R5.

    Does anyone have any idea about what's going on?  Is there some way that
my widget's supposed to be free'ing these things?  I looked at the Athena
widgets but didn't see anything that looked much different from how I'm doing
things.
					Thanks in advance
						-Joe Shapiro

p.s. here's the code fragment I promised above:

            case ICON:
#define DRAW_ICON( bitmap )   \
    XCopyPlane( display, (bitmap), window, gc,                          \
                0, 0,                                                   \
                prim -> pr.icon.width, prim -> pr.icon.height,          \
                prim -> xpr.icon.x, prim -> xpr.icon.y,                 \
                (unsigned long)1 )

                if ( prim -> pr.icon.mask_bitmap )
                    {
                    /*
                     * We special-case the gc here so that we can do somewhat-
                     * efficient icon masking.  The problem is that the clip-
                     * mask is embedded in the gc (which I consider a poor
                     * choice).  Thus, I've got to at least XSetClipMask() the
                     * gc.  If I didn't have a special default-gc, then I'd also
                     * have to set the clip-mask back to what it used to be.
                     */
                    if ( gc == w -> dl.default_gc )
                        {
                        gc = w -> dl.default_icon_gc;
                        XSetClipMask( display, gc, prim -> pr.icon.mask_bitmap);
                        XSetClipOrigin( display, gc,
                                        prim -> xpr.icon.x,
                                        prim -> xpr.icon.y );
***This one is used***  DRAW_ICON( prim -> pr.icon.icon_bitmap );
                        gc = w -> dl.default_gc;
                        }

                    /*
                     * If we're picking and there's a mask, then pick using the
                     * mask so that the inside of the icon is pickable even if
                     * it's whitespace.
                     */
                    else if ( flags & DO_PICK )
                        DRAW_ICON( prim -> pr.icon.mask_bitmap );

                    else
                        {
                        XSetClipMask( display, gc, prim -> pr.icon.mask_bitmap);
                        XSetClipOrigin( display, gc,
                                        prim -> xpr.icon.x,
                                        prim -> xpr.icon.y );
                        DRAW_ICON( prim -> pr.icon.icon_bitmap );
                        XSetClipMask( display, gc, None );
                        }
                    }

                else
                    DRAW_ICON( prim -> pr.icon.icon_bitmap );
#undef DRAW_ICON
                break;

---------------------------------------------------------------
Joe Shapiro (NOT Walter Gillett, though I'm using his account!)
Please send replies to:                        joe@ConSolve.com