[cairo] memory problem with the X11 - SHM backend
Uli Schlachter
psychon at znc.in
Sun Dec 1 01:55:27 PST 2013
Hi,
On 01.12.2013 01:06, Cedric Roux wrote:
> I have a problem running you with X11/Xshm. This is a debian host here.
> The following program reports an always increasing "evs" thing.
>
> The first line it outputs is "1 evs" and the last one is
> "7409 evs".
It doesn't do so here:
$ gcc t.c -lcairo -lX11 && ./a.out | uniq -c
7500 1 evs
(Looks like the first paint() causes a SHM fallback and all the following
paint()s don't cause any Xlib calls, but just draw to the already existing SHM
image surface)
If I do make the change mentioned below, I do get an increasing size of the
event queue. Why don't you run any event loop that gets events from Xlib?
> That means the X event queue is not emptied. (Please don't
> look at the style, it's a quick and dirty hack to let the problem pop
> up.)
>
> Oh yes, you need to create a 128x128 mini.png file to run it. Content
> does not seem to matter, I have a white image here.
>
> Am I doing something wrong with you or is the problem on your side?
Uhm, so what exactly is the problem here? So far we are just at the symptom
"always increasing 'evs' thing". This might cause many actual problems, so which
one are you looking at?
> If I call XSync(d, True) the queue is emptied and the original program
> that exhibited the problem and from which I wrote that little proof of
> concept still works pretty reasonably well. (What a terrific sentence
> I just wrote...)
> Except it smokes my CPU like hell, but that's none of your concern I
> suspect.
>
> In the hope that you can help me here...
> Regards cairo, have a nice sunday.
>
> #include <stdio.h>
> #include <cairo/cairo.h>
> #include <cairo/cairo-xlib.h>
> #include <X11/Xlib.h>
> #include <stdlib.h>
>
> int main(void)
> {
> cairo_surface_t *image;
> cairo_pattern_t *pletters;
> cairo_surface_t *cs;
> Display *d;
> Pixmap p;
>
> d = XOpenDisplay(0); if (!d) abort();
> p = XCreatePixmap(d, DefaultRootWindow(d), 256, 256,
> DefaultDepth(d, DefaultScreen(d)));
> cs = cairo_xlib_surface_create(d, p, DefaultVisual(d, DefaultScreen(d)),
> 256, 256);
>
> //image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 512, 512);
> image = cairo_image_surface_create_from_png("mini.png");
> pletters = cairo_pattern_create_for_surface(image);
>
> int y;
> for (y=0; y < 500; y++) {
> int i;
> cairo_matrix_t m;
> cairo_t *c = cairo_create(cs);
>
> //cairo_scale(c, 0.5, 0.5);
> //cairo_translate(c, 1, 1);
> for (i = 0; i < 15; i++) {
> //static int z = 2; cairo_matrix_init_translate(&m, 0, 0); //z =
> 2 - z;
> cairo_matrix_init_translate(&m, 0, 0); //z = 2 - z;
> cairo_pattern_set_matrix(pletters, &m);
> cairo_set_source(c, pletters);
> cairo_paint(c);
>
> //XSync(d, True);
> printf("%d evs\n", XEventsQueued(d, QueuedAfterReading));
> //XFlush(d);
>
> XEvent ev; while (XCheckMaskEvent(d, -1L, &ev)) {
> printf("event!\n"); }
Add here: cairo_surface_flush(cs); and the event queue gets filled with
MIT-SHM-Completion events (and the program of course runs a lot slower).
> }
>
> cairo_destroy(c);
> }
>
> return 0;
> }
>
Cheers,
Uli
--
<alanc> I think someone had a Xprint version of glxgears at one point,
but benchmarking how many GL pages you can print per second
was deemed too silly to merge
More information about the cairo
mailing list