Login  Register

Re: JOGL Textures Hogging Memory

Posted by gouessej on Aug 07, 2016; 9:34am
URL: https://forum.jogamp.org/JOGL-Textures-Hogging-Memory-tp4037027p4037028.html

Hi

Please use more accurate titles and don't overreact. No, JOGL textures don't hog memory. I remind you that JOGL is open source, I advise you to spend some time in studying its source code before making peremptory claims on its memory footprint even though you seem to ask some questions. Personally, I would have chosen a less aggressive title like "textures memory footprint".

I advise you to use JVisualVM. It will show you that the image raster of your buffered image probably occupies about (at least) 4 MB. If you use a JPEG image, JOGL simply will use Swing ImageIO under the hood to decode it, it might need to create another buffered image or two and of course it creates a texture data object, then at least 4 * 4 MB in the worst case.

You can reduce memory usage by using compressed textures (elect knows that better than me) or simply by using another image format that JOGL can decode without using Swing ImageIO, for example PNG. You can contribute to the JOGL JPEG decoder, it would drastically reduce your memory usage too. You can use TextureIO instead of AWTTextureIO and avoid passing any buffered image, it will reduce a bit your memory usage. By the way, Swing ImageIO has a kind of cache, you can disable it too, maybe it would make a small difference, look at javax.imageio.ImageIO.setUseCache().

You can use smaller images but it's probably not what you want to do.

Yes, some texture data are stored on the GPU but there are still numerous Java objects that contain the same data elsewhere. I try to store those data only in texture data objects.
Julien Gouesse | Personal blog | Website