From: eap Date: Mon, 7 Jul 2008 07:36:47 +0000 (+0000) Subject: [SALOME platform 0019911]: pb of memory allocation in SMESH X-Git-Tag: V4_1_4a1~45 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6da23ffa6f06803ad0216eae378de16cb293a4d8;p=modules%2Fsmesh.git [SALOME platform 0019911]: pb of memory allocation in SMESH call CheckMemory() not at any entity addition but after adding CHECKMEMORY_INTERVAL(=1000) entities. --- diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 637e105aa..02180dc5a 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -43,6 +43,9 @@ using namespace std; #include #endif +// number of added entitis to check memory after +#define CHECKMEMORY_INTERVAL 1000 + //================================================================================ /*! * \brief Raise an exception if free memory (ram+swap) too low @@ -151,7 +154,7 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID) // find the MeshNode corresponding to ID const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID); if(!node){ - CheckMemory(); + if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z); myNodes.Add(node); myNodeIDFactory->BindID(ID,node); @@ -200,7 +203,8 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, { if ( !n1 || !n2 ) return 0; - CheckMemory(); + if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + SMDS_MeshEdge * edge=new SMDS_MeshEdge(n1,n2); if(myElementIDFactory->BindID(ID, edge)) { SMDS_MeshNode *node1,*node2; @@ -339,7 +343,8 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1, return NULL; if ( !e1 || !e2 || !e3 ) return 0; - CheckMemory(); + if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3); myFaces.Add(face); myInfo.myNbTriangles++; @@ -379,7 +384,7 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1, if (!hasConstructionEdges()) return NULL; if ( !e1 || !e2 || !e3 || !e4 ) return 0; - CheckMemory(); + if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4); myFaces.Add(face); myInfo.myNbQuadrangles++; @@ -444,7 +449,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, { SMDS_MeshVolume* volume = 0; if ( !n1 || !n2 || !n3 || !n4) return volume; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3); SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n4); @@ -530,7 +535,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, { SMDS_MeshVolume* volume = 0; if ( !n1 || !n2 || !n3 || !n4 || !n5) return volume; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4); SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n5); @@ -620,7 +625,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, { SMDS_MeshVolume* volume = 0; if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6) return volume; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3); SMDS_MeshFace * f2=FindFaceOrCreate(n4,n5,n6); @@ -722,7 +727,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, { SMDS_MeshVolume* volume = 0; if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6 || !n7 || !n8) return volume; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionFaces()) { SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4); SMDS_MeshFace * f2=FindFaceOrCreate(n5,n6,n7,n8); @@ -782,7 +787,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1, if (!hasConstructionFaces()) return NULL; if ( !f1 || !f2 || !f3 || !f4) return 0; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4); myVolumes.Add(volume); myInfo.myNbTetras++; @@ -826,7 +831,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1, if (!hasConstructionFaces()) return NULL; if ( !f1 || !f2 || !f3 || !f4 || !f5) return 0; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5); myVolumes.Add(volume); myInfo.myNbPyramids++; @@ -872,7 +877,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1, if (!hasConstructionFaces()) return NULL; if ( !f1 || !f2 || !f3 || !f4 || !f5 || !f6) return 0; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6); myVolumes.Add(volume); myInfo.myNbPrisms++; @@ -910,7 +915,7 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID { SMDS_MeshFace * face; - CheckMemory(); + if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionEdges()) { MESSAGE("Error : Not implemented"); @@ -975,7 +980,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID const int ID) { SMDS_MeshVolume* volume; - CheckMemory(); + if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if (hasConstructionFaces()) { MESSAGE("Error : Not implemented"); return NULL; @@ -1046,7 +1051,7 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node3) { if ( !node1 || !node2 || !node3) return 0; - CheckMemory(); + if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionEdges()) { SMDS_MeshEdge *edge1, *edge2, *edge3; @@ -1078,7 +1083,7 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node4) { if ( !node1 || !node2 || !node3 || !node4 ) return 0; - CheckMemory(); + if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); if(hasConstructionEdges()) { SMDS_MeshEdge *edge1, *edge2, *edge3, *edge4; @@ -1363,7 +1368,7 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1, SMDS_MeshEdge * toReturn=NULL; toReturn=const_cast(FindEdge(node1,node2)); if(toReturn==NULL) { - CheckMemory(); + if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); toReturn=new SMDS_MeshEdge(node1,node2); myEdges.Add(toReturn); myInfo.myNbEdges++;