Commit edde29c3 by Christophe Geuzaine

Merge branch 'memory' into 'master'

Memory reduction of GMSH used as an external lib for ParaView plugin

See merge request !23
parents b195cd71 31b27f30
Pipeline #327 passed with stage
in 8 minutes 53 seconds
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment