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 ,:)_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org