<DIV>hi,</DIV>
<DIV>   Some days later,i have sent a email which is about this subject,and <SPAN class="sender">Gordon Tomlinson answered as this:</SPAN></DIV>
<DIV><SPAN class="sender"></SPAN> </DIV>
<DIV><SPAN class="sender">   >This is a compiler problem not an OSG problem, so you really need to ask<BR>   >Microsoft, it's a problem with their compiler and code not OSG</SPAN></DIV>
<DIV><SPAN class="sender"></SPAN> </DIV>
<DIV><SPAN class="sender">   this is my email before:</SPAN></DIV>
<DIV><SPAN class="sender">     >>>hi,<BR><BR>     >>>I am sorry to ask about this topic again,:). I have asked the same<BR>     >>>question before. That's about osgMFC example. Somebody in this email List<BR>     >>>have help me with it. And that's perfect.<BR>     >>> >>There is a known issue/BUG with MFC, were MFC makes a call to <BR>     >>> >>_CrtDumpMemoryLeaks() in the destructor of the _AFX_DEBUG_STATE, followed<BR>     >>> by _CrtSetDbgFlag() which sets it to ~_CRTDBG_LEAK_CHECK_DF (therefor<BR>     >>> >>disabling memory leak test at *true* program exit) This destructor is<BR>     >>> called at exit (i.e. atexit()), but before statics residing in dlls and<BR>     >>> >>others are destroyed, resulting in many false memory leaks are reported <BR><BR>     >>> I use VS2003 and osg2.4 in debug mode. In my project, i Just add<BR>     >>> mfc71d.lib before all of the osg Libs ,and the VS no longer report memory.<BR><BR>     >>> Unfortunately,recently the project report memory leak again. That is<BR>     >>> about osgUtil::Tessellator,Here is my test code:<BR>     >>> //the test code is drawing a concave like a rect containing a triangle with<BR>     >>> it .The Rect and the triangle intersect with one point,as <BR>     >>> //we can see bellow<BR><BR>     >>> //an concave polygon <BR><BR>     >>> //   *******************************<BR>     >>> //   *            * *              *<BR>     >>> //   *           *   *             *<BR>     >>> //   *          *     *            *<BR>     >>> //   *         *       *           *<BR>     >>> //   *        ***********          *<BR>     >>> //   *                             *<BR>     >>> //   *******************************<BR>     >>> osgViewer::Viewer viewer;<BR>     >>> osg::ref_ptr< osg::Vec3Array > vertices = new osg::Vec3Array;<BR>     >>> vertices->push_back(osg::Vec3(-100,0,-100));<BR>     >>> vertices->push_back(osg::Vec3(100,0,-100));<BR>     >>> vertices->push_back(osg::Vec3(100,0,100));<BR>     >>> vertices->push_back(osg::Vec3(0,0,100));<BR>     >>> vertices->push_back(osg::Vec3(50,0,50));<BR>     >>> vertices->push_back(osg::Vec3(-50,0,50));<BR>     >>> vertices->push_back(osg::Vec3(0,0,100));<BR>     >>> vertices->push_back(osg::Vec3(-100,0,100));</SPAN></DIV>
<DIV><SPAN class="sender">     >>> osg::ref_ptr< osg::Vec3Array > pNormal = new osg::Vec3Array();<BR>     >>> pNormal->push_back(osg::Vec3(0,-1,0));</SPAN></DIV>
<DIV><SPAN class="sender"><BR>     >>> osg::ref_ptr <osg::Geometry> geom = new osg::Geometry;</SPAN></DIV>
<DIV><SPAN class="sender">     >>> geom->setVertexArray(vertices.get());<BR>     >>> geom->setNormalArray(pNormal.get());<BR>     >>> geom->setNormalBinding(osg::Geometry::BIND_OVERALL);<BR>     >>> geom->addPrimitiveSet(new<BR>     >>> osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,vertices->size()));<BR>     >>> osg::ref_ptr< osgUtil::Tessellator > tes = new osgUtil::Tessellator();<BR>     >>> tes->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);<BR>     >>> tes->setBoundaryOnly(false);<BR>     >>> tes->setWindingType( osgUtil::Tessellator::TESS_WINDING_ODD);<BR>     >>> tes->retessellatePolygons(*geom);<BR><BR>     >>> osg::ref_ptr<osg::Geode> geode = new osg::Geode;<BR>     >>> geode->addDrawable(geom.get());</SPAN></DIV>
<DIV><SPAN class="sender">     >>> osg::ref_ptr<osg::Group> pGroup = new osg::Group;<BR>     >>> pGroup->addChild(geode.get());<BR>     >>> viewer.setSceneData( pGroup.get() );<BR><BR>     >>> I test this code in non-MFC project such as console project,that works<BR>     >>> perfect.No memory leak is reported. But when i turn to osg  MFC project,the<BR>     >>> VS always reports memory leak . I notice that if the polygon is<BR>     >>> self-intersect ,there must be memory leak report in MFC project.<BR><BR>     >>> I really do not know how to do about it . I just want to find a method to<BR>     >>> prevent the VS reprot false memory leak. Anyone help me? Thank you ,:)</SPAN></DIV>
<DIV><SPAN class="sender"> </SPAN></DIV>
<DIV><SPAN class="sender">     Recently i trace this memory leak In VS with osg2.4 osgviewerMFC project, i do find the problem.I modify the osg code:</SPAN></DIV>
<DIV><SPAN class="sender">         void Tessellator::reset()<BR>         {<BR>             if (_tobj)<BR>             {<BR>                 gluDeleteTess(_tobj);<BR>                 _tobj = 0;<BR>             }<BR>             for (Vec3dList::iterator i = _coordData.begin(); i != _coordData.end(); ++i) {<BR>                 delete (*i);<BR>             }</SPAN></DIV>
<DIV><SPAN class="sender">             _coordData.clear();<BR>             _newVertexList.clear();<BR>             _primList.clear();<BR>             _errorCode = 0;</SPAN></DIV>
<DIV><SPAN class="sender">         }</SPAN></DIV><SPAN class="sender">
<DIV><BR>         as below:</DIV>
<DIV></DIV></SPAN> 
<DIV><SPAN class="sender">         void Tessellator::reset()<BR>         {<BR>             if (_tobj)<BR>             {<BR>                  gluDeleteTess(_tobj);<BR>                  _tobj = 0;<BR>             }<BR>             for (Vec3dList::iterator i = _coordData.begin(); i != _coordData.end(); ++i) {<BR>                  delete (*i);<BR>             }</SPAN></DIV>
<DIV><SPAN class="sender">             osg::Vec3* vertex = NULL;<BR>             for (NewVertexList::iterator j = _newVertexList.begin(); j != _newVertexList.end(); ++j) {<BR>                   NewVertex& newVertex = (*j);<BR>                   vertex = newVertex._vpos;<BR>                   delete vertex;<BR>                   newVertex._vpos = NULL;<BR>             }<BR>             vertex = NULL;<BR>             _coordData.clear();<BR>             _newVertexList.clear();<BR>             _primList.clear();<BR>             _errorCode = 0;<BR>          }</SPAN></DIV>
<DIV><SPAN class="sender">          </SPAN></DIV>
<DIV><SPAN class="sender">          Then the memory leak report disappears,and this does perfect. As glu does, osgUtil::Tessalator can draw composite polygon containing concave polygon and self-intersecting polygon. </SPAN></DIV>
<DIV><SPAN class="sender">    </SPAN></DIV>
<DIV><SPAN class="sender"></SPAN> </DIV><br><!-- footer --><br> 
<hr>
<font style="font-size:12px;line-height:15px;">卡卡上网安全助手6.0,震撼上市,</font><a style="font-size:12px;line-height:15px; color:blue; text-decoration:underline;" href="http://popme.163.com/link/4634_0722_8883.html">绝杀木马!</a>