[osg-users] memory leak about osg MFC project AGAIN

Gordon Tomlinson gordon at gordon-tomlinson.com
Mon Jul 14 19:30:37 PDT 2008


This is a compiler problem not an OSG problem, so you really need to ask
Microsoft, it's a problem with their compiler and code not OSG

 

 

__________________________________________________________
Gordon Tomlinson 

__________________________________________________________

 

From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of
heishuijing_2000
Sent: Monday, July 14, 2008 9:32 PM
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] memory leak about osg MFC project AGAIN

 

hi,

    I am sorry to ask about this topic again,:). I have asked the same
question before. That's about osgMFC example. Somebody in this email List
have help me with it. And that's perfect.

 

>>There is a known issue/BUG with MFC, were MFC makes a call to 
>>_CrtDumpMemoryLeaks() in the destructor of the _AFX_DEBUG_STATE, followed
by _CrtSetDbgFlag() which sets it to ~_CRTDBG_LEAK_CHECK_DF (therefor
>>disabling memory leak test at *true* program exit) This destructor is
called at exit (i.e. atexit()), but before statics residing in dlls and
>>others are destroyed, resulting in many false memory leaks are reported 

    I use VS2003 and osg2.4 in debug mode. In my project, i Just add
mfc71d.lib before all of the osg Libs ,and the VS no longer report memory.

     

    Unfortunately,recently the project report memory leak again. That is
about osgUtil::Tessellator,Here is my test code:

 

 //the test code is drawing a concave like a rect containing a triangle with
it .The Rect and the triangle intersect with one point,as 

 //we can see bellow

 //an concave polygon 

 //   *******************************

 //   *            * *              *

 //   *           *   *             *

 //   *          *     *            *

 //   *         *       *           *

 //   *        ***********          *

 //   *                             *

 //   *******************************

 

 osgViewer::Viewer viewer;

 

 osg::ref_ptr< osg::Vec3Array > vertices = new osg::Vec3Array;

 

 vertices->push_back(osg::Vec3(-100,0,-100));
 vertices->push_back(osg::Vec3(100,0,-100));
 vertices->push_back(osg::Vec3(100,0,100));
 vertices->push_back(osg::Vec3(0,0,100));
 vertices->push_back(osg::Vec3(50,0,50));
 vertices->push_back(osg::Vec3(-50,0,50));
 vertices->push_back(osg::Vec3(0,0,100));
 vertices->push_back(osg::Vec3(-100,0,100));

 

 osg::ref_ptr< osg::Vec3Array > pNormal = new osg::Vec3Array();
 pNormal->push_back(osg::Vec3(0,-1,0));


 osg::ref_ptr <osg::Geometry> geom = new osg::Geometry;


 geom->setVertexArray(vertices.get());
 geom->setNormalArray(pNormal.get());
 geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
 geom->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,vertices->size()));

 

 osg::ref_ptr< osgUtil::Tessellator > tes = new osgUtil::Tessellator();
 tes->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
 tes->setBoundaryOnly(false);
 tes->setWindingType( osgUtil::Tessellator::TESS_WINDING_ODD);
 tes->retessellatePolygons(*geom);

 

 osg::ref_ptr<osg::Geode> geode = new osg::Geode;

 geode->addDrawable(geom.get());

 

 osg::ref_ptr<osg::Group> pGroup = new osg::Group;
 pGroup->addChild(geode.get());


 viewer.setSceneData( pGroup.get() );

 

 I test this code in non-MFC project such as console project,that works
perfect.No memory leak is reported. But when i turn to osg  MFC project,the
VS always reports memory leak . I notice that if the polygon is
self-intersect ,there must be memory leak report in MFC project.

 

 I really do not know how to do about it . I just want to find a method to
prevent the VS reprot false memory leak. Anyone help me? Thank you ,:)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080714/44955361/attachment-0003.htm>


More information about the osg-users mailing list