我的应用程序包含一个作为主时钟的 QTimer 和一个 GLCanvas 对象。计时器正在调用画布 updateGL 函数,然后 updateGL 调用paintGL。
我注意到大约 100kb/s 的大内存泄漏,即使paintGL 完全为空并且没有渲染任何内容,它仍然存在。如果我停止 updateGL 调用,内存泄漏就会消失。
尽管我的所有代码都被注释掉并且泄漏仍然存在。我需要做一些清理工作还是我犯了一个错误?任何帮助,将不胜感激。
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
}