From 2dcc1590a31ccc42dbc90f83e462a8bc4fbdb127 Mon Sep 17 00:00:00 2001 From: prascle Date: Thu, 20 Jun 2013 12:22:27 +0000 Subject: [PATCH] PR: debug memory leak (EDF 2662) non virtual destructors and missing delete... --- src/SMESH/SMESH_MeshEditor.cxx | 9 ++++--- src/SMESH/SMESH_MeshEditor.hxx | 1 + src/SMESHUtils/SMESH_Octree.hxx | 1 + src/SMESHUtils/SMESH_Tree.hxx | 44 +++++++++++++++++---------------- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index c6605815a..fc9202018 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -6360,7 +6360,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint() void getElementsInSphere ( const gp_XYZ& center, const double radius, TIDSortedElemSet& foundElems); size_t getSize() { return std::max( _size, _elements.size() ); } - ~ElementBndBoxTree(); + virtual ~ElementBndBoxTree(); protected: ElementBndBoxTree():_size(0) {} @@ -6559,6 +6559,9 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint() * of classification of point in 2D mesh */ //======================================================================= +SMESH_ElementSearcher::~SMESH_ElementSearcher() +{ +} struct SMESH_ElementSearcherImpl: public SMESH_ElementSearcher { @@ -6572,8 +6575,8 @@ struct SMESH_ElementSearcherImpl: public SMESH_ElementSearcher set _outerFaces; // empty means "no internal faces at all" SMESH_ElementSearcherImpl( SMESHDS_Mesh& mesh, SMDS_ElemIteratorPtr elemIt=SMDS_ElemIteratorPtr()) - : _mesh(&mesh),_meshPartIt(elemIt),_ebbTree(0),_nodeSearcher(0),_tolerance(-1),_outerFacesFound(false) {} - ~SMESH_ElementSearcherImpl() + : _mesh(&mesh),_meshPartIt(elemIt),_ebbTree(0),_nodeSearcher(0),_tolerance(-1),_outerFacesFound(false) {MESSAGE("-----------> SMESH_ElementSearcherImpl constructor");} + virtual ~SMESH_ElementSearcherImpl() { if ( _ebbTree ) delete _ebbTree; _ebbTree = 0; if ( _nodeSearcher ) delete _nodeSearcher; _nodeSearcher = 0; diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index bf1d3b7b1..5011d7f01 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -96,6 +96,7 @@ struct SMESH_ElementSearcher * \brief Find out if the given point is out of closed 2D mesh. */ virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0; + virtual ~SMESH_ElementSearcher(); }; diff --git a/src/SMESHUtils/SMESH_Octree.hxx b/src/SMESHUtils/SMESH_Octree.hxx index 5fa0e6533..adb74b560 100644 --- a/src/SMESHUtils/SMESH_Octree.hxx +++ b/src/SMESHUtils/SMESH_Octree.hxx @@ -49,6 +49,7 @@ public: // Constructor. limit must be provided at tree root construction. // limit will be deleted by SMESH_Octree SMESH_Octree (SMESH_TreeLimit* limit=0); + virtual ~SMESH_Octree() {}; // Compute the bigger dimension of my box double maxSize() const; diff --git a/src/SMESHUtils/SMESH_Tree.hxx b/src/SMESHUtils/SMESH_Tree.hxx index bf099d305..7704893d2 100644 --- a/src/SMESHUtils/SMESH_Tree.hxx +++ b/src/SMESHUtils/SMESH_Tree.hxx @@ -1,24 +1,24 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// // SMESH SMESH_Tree : tree implementation // File : SMESH_Tree.hxx @@ -218,6 +218,8 @@ void SMESH_Tree::buildChildren() myChildren[i] = newChild(); // and we assign to him its box. myChildren[i]->myFather = this; + if (myChildren[i]->myLimit) + delete myChildren[i]->myLimit; myChildren[i]->myLimit = myLimit; myChildren[i]->myLevel = myLevel + 1; myChildren[i]->myBox = newChildBox( i ); -- 2.39.2