3
\$\begingroup\$

Using OpenGL it is possible to load textures, buffer arrays, compiled shaders and more to the video memory. When a C++ program exits, heap memory that was allocated by it is cleaned. What happens to the stuff allocated on the video memory? Will memory leak beyond program's scope?

\$\endgroup\$
2
\$\begingroup\$

Your question was answered on SO:

https://stackoverflow.com/questions/2215088/opengl-gpu-memory-cleanup-required

Basically the answer is when your program exits, the memory should be cleared, so you will not have leaks.

You can test this by opening/closing multiple instances of your program without freeing the resources and verifying that your video memory usage stays the same.

However, as also mentioned in the link, you should of course get into the habit of freeing resources when they are no longer needed.

\$\endgroup\$
0
\$\begingroup\$

No. If the driver is written correctly, everything should be cleaned up just fine.

At least that's the theory. Drivers are rarely written 100% correctly; you may find on particular models of video cards, on particular OSs, you need to do some manual cleanup.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.