Native Buffer Management

Started by Vektor, November 04, 2017, 03:58:56

Previous topic - Next topic

Vektor

Hey Guys,

This is my first post but I have been working with LWJGL3 for a while now. Now that I've finally got around to making an account here I hope to be more active on these forums. Recently, I have been thinking a lot about various techniques for managing native buffers (created via glGenBuffers and set with glBufferData) in my game engine. I have been able to successfully manage the native buffer memory, but I do have a few questions that I haven't been able to easily find answers for anywhere else.

1.) What happens to the memory occupied by natively allocated buffers when the application or JVM terminates unexpectedly (like when a NullPointerException is thrown)? Are they automatically freed when the JVM exits or does the memory get "stuck" in the GPU until the next system restart?

2.) This question is somewhat related to my previous question. My engine is designed to automatically free any active buffers and vertex arrays via glDeleteBuffers() and glDeleteVertexArrays() when the application is stopped. Is it necessary to do this? Is there an easier way to free up ALL natively allocated buffers other than calling glDeleteBuffers() and glDeleteVertexArrays() on each one?

Some additional info: I am using memAlloc() to create the buffers. I am also freeing them using memFree() directly after passing the buffer data into glBufferData().

Cornix

When the application exits the OpenGL context is destroyed and with it all resources are automatically freed. There is no need to worry about memory leaks after the application has terminated.

Vektor

Thank you for the prompt response. That is exactly what I needed to know.