[Solved] Memory Leak Resizing OpenGL RTT

Problems building or running the engine, queries about how to use features etc.
Post Reply
MadMan
Gnoblar
Posts: 5
Joined: Wed Jul 27, 2016 10:31 pm

[Solved] Memory Leak Resizing OpenGL RTT

Post by MadMan »

Hello everyone,

I am using an RTT with OpenGl to render my scene. The game window can be set to random sizes via drag´n´drop. Whenever it resizes, I change the size of the texture this way:

Code: Select all

texture->freeInternalResources();
texture->setWidth(width);
texture->setHeight(height);
texture->createInternalResources();
The next time the texture is rendered, OGRE creates a new DepthBuffer. Those DepthBuffers never get deleted and as far as I can tell there is no way to do so in the OgreGLRenderSystem for non-RenderWindow RenderTargets.
So if I resize my window a few times, there is a huge amount of memory used by those DepthBuffers. There seems to be no difference, if I remove the texture completely and recreate it.
Am I missing some cleanup-call?

Furthermore if I work around this bug by setting the DepthBuffer manually, my app freezes after a few resizes during a call to an OpenGl-method. So there seem to be more memory issues, which I didnt have time yet to look into.

I am currently using Ogre 1.8, but there seem to have been no changes in 1.9 to OgreGLRenderSystem regarding DepthBuffers.

Thanks in advance.
Last edited by MadMan on Tue Jan 31, 2017 11:23 pm, edited 1 time in total.
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: Memory Leak Resizing OpenGL RTT

Post by frostbyte »

I am currently using Ogre 1.8, but there seem to have been no changes in 1.9 to OgreGLRenderSystem regarding DepthBuffers.
you probably already know that you should move to 1.10 and build it from source( default branch on bitBucket repo )
its the only 1.x branch that is being activity maintained and developed, so any problem can be fixed by issuing a JIRA ticket.
as a bonus you'll get:
1)all the stability fixes( 4 years commits )
2)DX11 and GL3+ with geometry and compute shaders
3)HLMS with PBS materials( much better than RTSS fixed function materials )
3.5)some new cool demos and components e.g progressive mesh, volume component, gpu particles etc...
4)various build targets( browser, current IOS and android version,etc... )
5)and most importantly you can use Ogitor's code as reference :)
api differences are not that big( you'll need to manually initialize overlays )
its a HUGE small step...so much to gain for so little effort....
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
MadMan
Gnoblar
Posts: 5
Joined: Wed Jul 27, 2016 10:31 pm

Re: Memory Leak Resizing OpenGL RTT

Post by MadMan »

Thank you frostbyte for your reply.
you probably already know that you should move to 1.10
You are absolutely right. I just was not sure, wether to switch to 1.10 or to 2.1. I decided to go for 1.10, but sadly the problem is the same.
5)and most importantly you can use Ogitor's code as reference :)
It seems, that Ogitor does not use RTT, which is causing the leak for me.

There is one thing about the DepthBuffer I do not understand: It is created for a RenderWindow the first time it gets rendered. But this buffer does not change size, even if the RenderWindow does. Is it resized only internally (OpenGL sided)?
Otherwise this could cause corrupted memory.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Memory Leak Resizing OpenGL RTT

Post by dark_sylinc »

By default Ogre keeps these depth buffers because it is very likely that they will be reused... but not in your case.

You can explicitly call RenderSystem::_cleanupDepthBuffers( false ); when you resize to get rid of these depth buffer left overs
MadMan
Gnoblar
Posts: 5
Joined: Wed Jul 27, 2016 10:31 pm

Re: Memory Leak Resizing OpenGL RTT

Post by MadMan »

Thank you dark_sylinc.

That did the trick.
Post Reply