I studied opengl and wrote a simple program that uses a buffer object (colors, positions, normals, element indices) to draw a shape as shown below. Even when uninstalling and expanding, the GPU monitor program shows an increase in memory usage after each button press. Memory is freed only when the application is closed. If I press the button repeatedly, the GPU tuner fills up to 2 GB and starts to multiply to accommodate RAM. How can I free resources / buffers correctly?

The program stream is similar:
When I click a button, the below program is executed: glControl1.MakeCurrent(); GL.GenBuffers(4,buf) GL.BindBuffer(BufferTarget.ArrayBuffer,buf[0]) GL.BufferData(BufferTarget.ArrayBuffer,......) same for buf[1] buf[2] and buf[3](this one ElementArrayBuffer) Console.WriteLine(GL.GetError()); // no error GL.Finish(); [iteration loop] glControl1.MakeCurrent(); GL.BindBuffer(BufferTarget.ArrayBuffer,buf[0]) GL.ColorBuffer(....) GL.BindBuffer(BufferTarget.ArrayBuffer,buf[1]) GL.VertexBuffer(....) GL.BindBuffer(BufferTarget.ArrayBuffer,buf[2]) GL.NormalBuffer(....) GL.BindBuffer(BufferTarget.ElementArrayBuffer,buf[3]) GL.EnableClientStates(.....) GL.DrawElements(.....) //draws the thing GL.DisableClientStates(.....) GL.BindBuffer(BufferTarget.ElementArrayBuffer,0) //is this unbinding? GL.BindBuffer(BufferTarget.ArrayBuffer,0) GL.BindBuffer(BufferTarget.ArrayBuffer,0) GL.BindBuffer(BufferTarget.ArrayBuffer,0) GL.Finish(); [loop end] //deleting buffers glControl1.MakeCurrent() GL.DeleteBuffers(4,buf) Console.WriteLine(GL.GetError()); // no error comes GL.Finish();
source share