Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualmshafey

Posted 15 February 2012 - 10:18 AM


Thanks for the suggestion. I've tried your code, it works, but it doesn't fix the leak. I'm still seeing memory leaking at the same rate on the affected platforms.

That's interesting.  Let's try to pin down which call is causing it.  What happens if you comment out the glTexSubImage2D call?  And if you comment out the glMapBuffer block (but leave glTexSubImage2D in and coming from the PBO)?


gDEBugger with the code I posted in the first post. Upon application exit it says "Checking for memory leaks - Context 1 deleted. Memory Leak: 2 object(s) are leaked in GL Context 1 [Leak Size: 2,400KB]". Here are Process Explorer graphs for the original code running for a few minutes.

GPU graph: http://i.imgur.com/KgXix.png
Performance graph: http://i.imgur.com/bD9RH.png

I took out glMapBuffer()/glUnmapBuffer() block. Leak persists. Same for the glTexSubImage2D() call. Took them both out and still. Which lead me to remove everything except just basic calls to draw a rectangle switching colors. I'm sorry I sent everyone in the wrong direction here. It seems like even the most basic GL code causes Windows 7 machines to leak memory. I trimmed it down to this and it still leaks.


void paintGL();
void timerCallback(int value);
void changeSize(int w, int h);

unsigned char c = 255;

int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(300, 300);
	glutInitWindowSize(640, 480);
	int windowHandle = glutCreateWindow("Window");
	glutDisplayFunc(paintGL);
	glutReshapeFunc(changeSize);
	timerCallback(0);
	glutMainLoop();
	glutDestroyWindow(windowHandle);
	return 0;
}

void paintGL()
{
	c = c? 0 : 255;
	glColor3ub(c, c, c);
	glBegin(GL_QUADS);
	{
		glVertex3f(-1, 1, 0);
		glVertex3f(1, 1, 0);
		glVertex3f(1, -1, 0);
		glVertex3f(-1, -1, 0);
	}
	glEnd();

        glutSwapBuffers();
}

void changeSize(int w, int h)
{
	glViewport(0, 0, w, h);
}

void timerCallback(int value)
{
	glutPostRedisplay();
	glutTimerFunc(5, timerCallback, 0);
}


I might add that in some runs, this code starts off at about 18 MB and goes up to and then stabilizes at 40 MB in a 5-6 minutes.

#2mshafey

Posted 15 February 2012 - 10:17 AM


Thanks for the suggestion. I've tried your code, it works, but it doesn't fix the leak. I'm still seeing memory leaking at the same rate on the affected platforms.

That's interesting.  Let's try to pin down which call is causing it.  What happens if you comment out the glTexSubImage2D call?  And if you comment out the glMapBuffer block (but leave glTexSubImage2D in and coming from the PBO)?


gDEBugger with the code I posted in the first post. Upon application exit it says "Checking for memory leaks - Context 1 deleted. Memory Leak: 2 object(s) are leaked in GL Context 1 [Leak Size: 2,400KB]". Here are Process Explorer graphs for the original code running for a few minutes.

GPU graph: http://i.imgur.com/KgXix.png
Performance graph: http://i.imgur.com/bD9RH.png

I took out glMapBuffer()/glUnmapBuffer() block. Leak persists. Same for the glTexSubImage2D() call. Took them both out and still. Which lead me to remove everything except just basic calls to draw a rectangle switching colors. I'm sorry I sent everyone in the wrong direction here. It seems like even the most basic GL code causes Windows 7 machines to leak memory. I trimmed it down to this and it still leaks.


void paintGL();
void timerCallback(int value);
void changeSize(int w, int h);

unsigned char c = 255;

int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(300, 300);
	glutInitWindowSize(640, 480);
	int windowHandle = glutCreateWindow("Window");
	glutDisplayFunc(paintGL);
	glutReshapeFunc(changeSize);
	timerCallback(0);
	glutMainLoop();
	glutDestroyWindow(windowHandle);
	return 0;
}

void paintGL()
{
	c = c? 0 : 255;
	glColor3ub(c, c, c);
	glBegin(GL_QUADS);
	{
		glVertex3f(-1, 1, 0);
		glVertex3f(1, 1, 0);
		glVertex3f(1, -1, 0);
		glVertex3f(-1, -1, 0);
	}
	glEnd();

    glutSwapBuffers();
}

void changeSize(int w, int h)
{
	glViewport(0, 0, w, h);
}

void timerCallback(int value)
{
	glutPostRedisplay();
	glutTimerFunc(5, timerCallback, 0);
}


I might add that in some runs, this code starts off at about 18 MB and goes up to and then stabilizes at 40 MB in a 5-6 minutes.

#1mshafey

Posted 15 February 2012 - 10:15 AM


Thanks for the suggestion. I've tried your code, it works, but it doesn't fix the leak. I'm still seeing memory leaking at the same rate on the affected platforms.

That's interesting.  Let's try to pin down which call is causing it.  What happens if you comment out the glTexSubImage2D call?  And if you comment out the glMapBuffer block (but leave glTexSubImage2D in and coming from the PBO)?


gDEBugger with the code I posted in the first post. Upon application exit it says "Checking for memory leaks - Context 1 deleted. Memory Leak: 2 object(s) are leaked in GL Context 1 [Leak Size: 2,400KB]". Here are Process Explorer graphs for the original code running for a few minutes.

GPU graph: http://i.imgur.com/KgXix.png
Performance graph: http://i.imgur.com/bD9RH.png

I took out glMapBuffer()/glUnmapBuffer() block. Leak persists. Same for the glTexSubImage2D() call. Took them both out and still. Which lead me to remove everything except just basic calls to draw a rectangle switching colors. I'm sorry I sent everyone in the wrong direction here. It seems like even the most basic GL code causes Windows 7 machines to leak memory. I trimmed it down to this and it still leaks.


void paintGL();
void timerCallback(int value);
void changeSize(int w, int h);

unsigned char c = 255;

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(300, 300);
    glutInitWindowSize(640, 480);
    int windowHandle = glutCreateWindow("Window");
    glutDisplayFunc(paintGL);
    glutReshapeFunc(changeSize);
    timerCallback(0);
    glutMainLoop();
    glutDestroyWindow(windowHandle);
    return 0;
}

void paintGL()
{
    c = c? 0 : 255;
    glColor3ub(c, c, c);
    glBegin(GL_QUADS);
    {
        glVertex3f(-1, 1, 0);
        glVertex3f(1, 1, 0);
        glVertex3f(1, -1, 0);
        glVertex3f(-1, -1, 0);
    }
    glEnd();

glutSwapBuffers();
}

void changeSize(int w, int h)
{
    glViewport(0, 0, w, h);
}

void timerCallback(int value)
{
    glutPostRedisplay();
    glutTimerFunc(5, timerCallback, 0);
}


I might add that in some runs, this code starts off at about 18 MB and goes up to and then stabilizes at 40 MB in a 5-6 minutes.

PARTNERS