Is the use of glDelete* necessary when using LWJGL

marnix :

I am currently working on a project involving LWJGL. I know that in C and C++ one should call functions like: glDeleteBuffers, glDeleteVertexArrays and such to free memory. However, Java has a Garbage Collector which typically means that all memory is freed when the JVM shuts down. Is it necessary to call glDelete* when using Java? Perhaps I should only call these functions earlier on for objects that are not needed anymore to improve performance.

Nicol Bolas :

OpenGL objects are not part of Java's garbage collection scheme, and my understanding is that LWJGL does nothing to attempt to wrap them in something that will automatically collect them (since that would be exceedingly difficult).

Anything OpenGL objects that you don't delete will eventually be destroyed when your program terminates, so the main concern would be if you run your application for some length of time and just drop things you don't use on the floor instead of deleting them. For simplistic apps that are just going to load some stuff at the beginning and run, that's fine. For anything of significant complexity, you're going to have to work out a time to delete objects you're not using.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=327080&siteId=1