[osg-users] VAO Resource Leak in OSG 3.6.2

Guy Volckaert guy.volckaert at meggitt.com
Fri Aug 10 17:53:34 PDT 2018


I suggest that we remove Geometry::dirtyGLObjects() as it does nothing other than call its base class, i.e. Drawable::dirtyGLObjects().  


Code:

void Geometry::dirtyGLObjects()     
{
    Drawable::dirtyGLObjects();    
}





I also noticed that the Drawable's destructor is calling a virtual function which is never a good idea, i.e. it's calling dirtyGLObjects(). I also suggest changing the dirtyGLObjects() to NOT BE virtual. 


Code:

Drawable::~Drawable()
{
    dirtyGLObjects();    // WARNING: Not a good idea to call a virtual function within a destructor. 
}





Although Julien Valentin suggested changing the Geometry's destructor with respect resolving the Gl object resource leak, I wonder if it would not be better to move that code to the Drawable's destructor. Here is my suggestion instead:
  

Code:
  
void Drawable::~Drawable()
{
    unsigned int i;
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
    for(i=0;i<_globjList.size();++i)
    {
        if (_globjList[i] != 0)
        {
            Drawable::deleteDisplayList(i,_globjList[i], getGLObjectSizeHint());
            _globjList[i] = 0;
        }
    }
#endif

[color=red]    for(i=0; i<_vertexArrayStateList.size(); ++i)
    {
        VertexArrayState* vas = _vertexArrayStateList[i].get();
        if (vas) vas->release();
    }[/color]
}





------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74498#74498







More information about the osg-users mailing list