Login  Register

Re: JOGL Textures Hogging Memory

Posted by gouessej on Aug 10, 2016; 8:26am
URL: https://forum.jogamp.org/JOGL-Textures-Hogging-Memory-tp4037027p4037043.html

JimmyNeutron wrote
Okay, so you're saying that even though I no longer maintain a reference to a Texture object, the VM won't garbage collect it until it's running short of memory? That would certainly explain why the memory footprint stays despite the fact that I have absolutely no reference to the texture object anywhere at all. Thanks for the advice.
It's the principle of garbage collection in general, there is a latency between disuse and reclaim. Of course, avoiding to maintain a reference on a useless object helps and is necessary to allow the garbage collector to do its job. Maybe you shouldn't worry. I advise you to force the garbage collection in JVisualVM (it's in the JDK) and to look at the memory usage. If you see that it increases despite the forced garbage collections and even though you no longer use some textures or images, then maybe you have an high memory usage or a memory leak. Otherwise, you don't have to worry except if you really want to decrease the memory usage of your software (then use another image format + TextureIO + file / input stream and no buffered images at all).
Julien Gouesse | Personal blog | Website