[cairo] memory problem with the X11 - SHM backend
Cedric Roux
sed at free.fr
Sat Nov 30 16:06:53 PST 2013
Hi cairo,
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". 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?
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"); }
}
cairo_destroy(c);
}
return 0;
}
More information about the cairo
mailing list