PDA

View Full Version : memory leak from closing pixmap windows



gawler
09-29-2004, 11:57 PM
Hi,

Hope one of the OpenGL gurus can give us a hand.
I've got a sample code below, but basically it results in a continuously growing memory usage and we have no idea why.
Under OSX it accumulates the memory in the sample program, but under LINUX it adds the memory to X and eventually results in X crashing and restarting itself.
We ran this code and used 'top' in another window to look at X's memory usage. The memory usage for X went up 10 megs for every 30000 loops of the code.
The way we would like the program to run is to not have a continuous increase in memory, so if anyone could show us how to do that, we would be grateful. The only clue is that the sample code doesn't exhibit that behavior when the call to glXChooseVisual is commented out.

Thank you.
\
\

int main( int argc, char** argv ) {
Display *display;
int i;
XVisualInfo *vi;
int configuration[] = { GLX_DOUBLEBUFFER, GLX_RGBA, GLX_DEPTH_SIZE, 16,
GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, None};

for ( i = 0 ; ; i++ ) {
/* Open X Display */
display = XOpenDisplay(NULL);
if (display == NULL) {
fprintf(stderr,"Cannot open display.\n");
exit(EXIT_FAILURE);
}

if (!glXQueryExtension(display, NULL, NULL)) {
fprintf(stderr,"X server has no OpenGL GLX extension\n");
exit(EXIT_FAILURE);
} vi = glXChooseVisual(display, DefaultScreen(display), &configuration[1]);

/* Clean Up */
XFree( vi );
XSetCloseDownMode(display, DestroyAll);
XCloseDisplay(display);

printf("Opened and closed X window %d times\r", i);
}
}