简体   繁体   中英

QT OpenGL Memory Leak

My application contains a QTimer, as the main clock, and a GLCanvas object. The timer is calling the canvas updateGL function and the updateGL then calls the paintGL.

I noticed a big memory leak of approximately 100kb/s which exists even if paintGL is completely empty and nothing is being rendered. If I stop the updateGL call, the memory leak disappears.

Although all my code is commented out and the leak persists. Is there some sort of clearing I need to do or did I make a mistake? Any help would be appreciated.

    void GLCanvas::initializeGL() {
        glClearColor(21.0f/256.0f,21.0f/256.0f, 21.0f/256.0f, 1);
        glEnable(GL_DEPTH_TEST);
        glDepthFunc(GL_LEQUAL);
    }

    void GLCanvas::resizeGL(int width, int height) {
        glViewport(0, 0, width, height);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(45, (float)width/(float)height, 1, 1000);
        glMatrixMode(GL_MODELVIEW);
    }



    void GLCanvas::paintGL() {
        // Nothing
    }

How often do your timer call update()?

What is the timer for? Maybe you can work your way out of the Qtimer for such important task.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM