> From: [EMAIL PROTECTED]
> Date: Wed, 31 Jul 2002 04:19:58 +0900
>
> Thanks to Mr. Wertmann, I found a good sample of xvideo at
> 
>   http://www.cs.uni-potsdam.de/~wertmann/xv/testxv.c
> 
> I just tried this and found that the process size becomes
> bigger and bigger while running. According to my quick study,
> it seems memory leak is in XvShmPutImage(). My environment
> is PIII dual (440BX) / Linux 2.4.18 / Debian 3.0 /
> XFree86 4.1.0 with GeForce2 MX400 (nvidia driver 1.0-2960).
> 
> Does someone know how to stop the memory leak ?

The testvx.c program calls XShmPutImage(..., True).  That final
True parameter tells the X server to send SHM completion events
after copying images to the video hardware, but the textxv.c
program never waits for those events so they accumulate in Xlib's
event queue.

You can hide the problem by passing False as the last parameter.
To truly fix it, though, you must wait for completion events.
The event type must be computed at run-time.  Interestingly,
testxv.c *does* compute the completion event type, but doesn't
use it.

Then, inside the loop, after calling XvShmPutImage(..., True)
you should call XFlush(display) to force Xlib to send the request
to the server immediately, and then repeatedly call XNextEvent(...)
until you see the completion event.

        XFlush(dpy);
        do
                XNextEvent(dpy, &event);
        while (event.type != CompletionType);

The testxv.c program has an XFlush(display) call, but it's commented
out.  Because of this, the XShmPutImage(...) requests are all queued
until Xlib's request queue fills up, at which time they are all sent
in one big chunk.  This could make the "frames per second" value
fluctuate wildly, giving meaningless results.  It wouldn't look very
good on the screen, either.  But try replacing the commented-out
XFlush(...) call with the above code, first.

Also, testxv.c calls XGetGeometry() inside the loop.  I believe
this is a round-trip request (can somebody confirm that?) which
would slow down the display loop.  You'd be better off watching
for ConfigureNotify events.
_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert

Reply via email to