diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index 28b5a767b329def1fd56bad431ab63c0368b7eac..103dee45b653c1a10412cb35fede545ee392d9f9 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -240,18 +240,16 @@ int GmshFinalize() { #if defined(HAVE_POST) // Delete all PViewData stored in static list of PView class - for(unsigned int i = 0; i < PView::list.size(); i++) { - delete PView::list[i]; - } - PView::list.clear(); + while(PView::list.size()>0) delete PView::list[PView::list.size()-1]; + std::vector<PView*>().swap(PView::list); // Delete static _interpolationSchemes of PViewData class PViewData::removeAllInterpolationSchemes(); #endif + // Delete all Gmodels - for(unsigned int i = 0; i < GModel::list.size(); i++) - delete GModel::list[i]; - GModel::list.clear(); + while(GModel::list.size()>0) delete GModel::list[GModel::list.size()-1]; + std::vector<GModel*>().swap(GModel::list); return 1; } diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 2d168c6d41e0a106e6f1a6a740a12b2e1ecf93c8..cd14f1a54a6e4549da3901932a182f25cc1d0e53 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -195,6 +195,7 @@ void GModel::destroy(bool keepName) for(riter it = firstRegion(); it != lastRegion(); ++it) delete *it; regions.clear(); + std::set<GRegion*, GEntityLessThan>().swap(regions); std::vector<GFace*> to_keep; for(fiter it = firstFace(); it != lastFace(); ++it){ @@ -206,15 +207,18 @@ void GModel::destroy(bool keepName) delete *it; } faces.clear(); + std::set<GFace*, GEntityLessThan>().swap(faces); faces.insert(to_keep.begin(), to_keep.end()); for(eiter it = firstEdge(); it != lastEdge(); ++it) delete *it; edges.clear(); + std::set<GEdge*, GEntityLessThan>().swap(edges); for(viter it = firstVertex(); it != lastVertex(); ++it) delete *it; vertices.clear(); + std::set<GVertex*, GEntityLessThan>().swap(vertices); destroyMeshCaches(); @@ -232,10 +236,15 @@ void GModel::destroy(bool keepName) void GModel::destroyMeshCaches() { _vertexVectorCache.clear(); + std::vector<MVertex*>().swap(_vertexVectorCache); _vertexMapCache.clear(); + std::map<int, MVertex*>().swap(_vertexMapCache); _elementVectorCache.clear(); + std::vector<MElement*>().swap(_elementVectorCache); _elementMapCache.clear(); + std::map<int, MElement*>().swap(_elementMapCache); _elementIndexCache.clear(); + std::map<int, int>().swap(_elementIndexCache); delete _octree; _octree = 0; } diff --git a/Post/PViewData.cpp b/Post/PViewData.cpp index 760c7f14712997e1897a71a499c4cfc3fe56a057..59d56e5155b7a33ff0feac502e4407cc291d5402 100644 --- a/Post/PViewData.cpp +++ b/Post/PViewData.cpp @@ -205,6 +205,7 @@ void PViewData::removeAllInterpolationSchemes() for(unsigned int i = 0; i < it2->second.size(); i++) delete it2->second[i]; _interpolationSchemes.clear(); + std::map<std::string, interpolationMatrices>().swap(_interpolationSchemes); } void PViewData::addMatrixToInterpolationScheme(const std::string &name, int type, diff --git a/Post/adaptiveData.h b/Post/adaptiveData.h index 488bf274346a17e8c0bd9cebd85b6aaf4d987d84..2d82e2536b056308a35b5cdb061160752ee8b591 100644 --- a/Post/adaptiveData.h +++ b/Post/adaptiveData.h @@ -462,18 +462,22 @@ class globalVTKData { it->clear(); } vtkGlobalConnectivity.clear(); + std::vector<vectInt>().swap(vtkGlobalConnectivity); } static void clearGlobalCellType() { vtkGlobalCellType.clear(); + std::vector<int>().swap(vtkGlobalCellType); } static void clearGlobalCoords() { vtkGlobalCoords.clear(); + std::vector<PCoords>().swap(vtkGlobalCoords); } static void clearGlobalValues() { vtkGlobalValues.clear(); + std::vector<PValues>().swap(vtkGlobalValues); } static void clearGlobalData() {