GL_STREAM_DRAW leads possible memory leak and high CPU occupation

Dear all

It is my first time posting questions here as I am now starting using OpenGL to do simple rendering programs. I have located the problem to the GL_STREAM_DRAW.

When I ran the program, system monitor will show nearly 100% CPU usage (fan keeps running) and memory usage keeps growing around 50k per sec. When I comment out the glMapBuffer(), everything becomes normal.

The two functions are as below. The initScence will be run once and the renderScene will be run in a loop in a separate thread.

Any thoughts about this would be appreciated. Thanks guys.

I am using:
Status: Using GLFW 3.0.4 X11 GLX glXGetProcAddress clock_gettime /dev/js
Status: Using GLEW 1.11.0
OpenGL version supported by this platform: 3.0 Mesa 8.0.4
OpenGL verdor supported by this platform: nouveau
OpenGL renderer supported by this platform: Gallium 0.4 on NVD9
GLSL version supported by this platform: 1.30

void InitScene() {
glGenVertexArrays(1, &vao_);

/// data

glGenBuffers(1, &vbo_);
glBindBuffer(GL_ARRAY_BUFFER, vbo_);
glBufferData(GL_ARRAY_BUFFER, sizeof(data…), NULL, GL_STREAM_DRAW);

/// Specify the layout of the vertex data
GLint pos_attrib = GetAttribLocation(“vPosition”);
glVertexAttribPointer(pos_attrib, 2, GL_FLOAT, GL_FALSE, 0, 0);

glBindBuffer(GL_ARRAY_BUFFER, 0);

void RenderScene() {
glBindBuffer(GL_ARRAY_BUFFER, vbo_);
GLfloat* buffer_ptr = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);

/// Change buffer data through buffer_ptr


/// Draw
glBindBuffer(GL_ARRAY_BUFFER, 0);

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.