Page 1 of 1

OpenGLRenderer Memory Leak - 0.7.5

Posted: Wed Nov 24, 2010 13:16
by royconejo
Hello =)

I've found a "bug" in CEGUIOpenGLRenderer, basically d_rendererID is declared as static and initialized once with this constructor:

Code: Select all

String OpenGLRenderer::d_rendererID(
"CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.");


and it's ok since It should never change. But it does:

Code: Select all

    // prefer FBO

    if (((tt_type == TTT_AUTO) || (tt_type == TTT_FBO)) &&
        GLEW_EXT_framebuffer_object)
    {
        d_rendererID += "  TextureTarget support enabled via FBO extension.";
        d_textureTargetFactory =
            new OGLTemplateTargetFactory<OpenGLFBOTextureTarget>;
    }


Whenever a CEGUIOpenGLRenderer is destroyed an re-created, a new " TextureTarget support enabled via FBO extension." string is appended to this static variable. After only a few iterations, the result of calling String& OpenGLRenderer::getIdentifierString() is something like this:

"CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module. TextureTarget support enabled via FBO extension. TextureTarget support enabled via FBO extension. TextureTarget support enabled via FBO extension. TextureTarget support enabled via FBO extension. TextureTarget support enabled via FBO extension. TextureTarget support enabled via FBO extension. TextureTarget support enabled via FBO extension. TextureTarget support enabled via FBO extension."


I've found it because I'm doing a sort of "application launcher" that needs to bootstrap and finally destroy CEGUI whenever it loads a new application to ensure a clean CEGUI environment for each app.

I personally think static should be removed in this particular case...

Thanks!

Re: OpenGLRenderer Memory Leak - 0.7.5

Posted: Wed Nov 24, 2010 15:50
by Jamarr
This is not a memory leak, it is a logic error. And it can be fixed without alter the scope of the variable. We should not simply assume the id is static for no reason. Alternatively we could simply log texture-target support on it's own, instead of appending it to the renderer-id to be logged along side it later. And it makes little sense to append feature-support to the renderer-id anyway. But thanks for catching this :wink:

Re: OpenGLRenderer Memory Leak - 0.7.5

Posted: Thu Dec 02, 2010 15:37
by Kulik
I will look into this.. I think OpenGL renderer shouldn't be appending text to the static ID String at all.