mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-03-01 02:15:37 +05:00
[SALOME platform 0019911]: pb of memory allocation in SMESH
call CheckMemory() not at any entity addition but after adding CHECKMEMORY_INTERVAL(=1000) entities.
This commit is contained in:
parent
9ea74d4371
commit
6da23ffa6f
@ -43,6 +43,9 @@ using namespace std;
|
|||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// number of added entitis to check memory after
|
||||||
|
#define CHECKMEMORY_INTERVAL 1000
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Raise an exception if free memory (ram+swap) too low
|
* \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
|
// find the MeshNode corresponding to ID
|
||||||
const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
|
const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID);
|
||||||
if(!node){
|
if(!node){
|
||||||
CheckMemory();
|
if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z);
|
SMDS_MeshNode * node=new SMDS_MeshNode(x, y, z);
|
||||||
myNodes.Add(node);
|
myNodes.Add(node);
|
||||||
myNodeIDFactory->BindID(ID,node);
|
myNodeIDFactory->BindID(ID,node);
|
||||||
@ -200,7 +203,8 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
|
|||||||
{
|
{
|
||||||
if ( !n1 || !n2 ) return 0;
|
if ( !n1 || !n2 ) return 0;
|
||||||
|
|
||||||
CheckMemory();
|
if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
|
|
||||||
SMDS_MeshEdge * edge=new SMDS_MeshEdge(n1,n2);
|
SMDS_MeshEdge * edge=new SMDS_MeshEdge(n1,n2);
|
||||||
if(myElementIDFactory->BindID(ID, edge)) {
|
if(myElementIDFactory->BindID(ID, edge)) {
|
||||||
SMDS_MeshNode *node1,*node2;
|
SMDS_MeshNode *node1,*node2;
|
||||||
@ -339,7 +343,8 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1,
|
|||||||
return NULL;
|
return NULL;
|
||||||
if ( !e1 || !e2 || !e3 ) return 0;
|
if ( !e1 || !e2 || !e3 ) return 0;
|
||||||
|
|
||||||
CheckMemory();
|
if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
|
|
||||||
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
|
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
|
||||||
myFaces.Add(face);
|
myFaces.Add(face);
|
||||||
myInfo.myNbTriangles++;
|
myInfo.myNbTriangles++;
|
||||||
@ -379,7 +384,7 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshEdge * e1,
|
|||||||
if (!hasConstructionEdges())
|
if (!hasConstructionEdges())
|
||||||
return NULL;
|
return NULL;
|
||||||
if ( !e1 || !e2 || !e3 || !e4 ) return 0;
|
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);
|
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4);
|
||||||
myFaces.Add(face);
|
myFaces.Add(face);
|
||||||
myInfo.myNbQuadrangles++;
|
myInfo.myNbQuadrangles++;
|
||||||
@ -444,7 +449,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
|
|||||||
{
|
{
|
||||||
SMDS_MeshVolume* volume = 0;
|
SMDS_MeshVolume* volume = 0;
|
||||||
if ( !n1 || !n2 || !n3 || !n4) return volume;
|
if ( !n1 || !n2 || !n3 || !n4) return volume;
|
||||||
CheckMemory();
|
if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if(hasConstructionFaces()) {
|
if(hasConstructionFaces()) {
|
||||||
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
|
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
|
||||||
SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n4);
|
SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n4);
|
||||||
@ -530,7 +535,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
|
|||||||
{
|
{
|
||||||
SMDS_MeshVolume* volume = 0;
|
SMDS_MeshVolume* volume = 0;
|
||||||
if ( !n1 || !n2 || !n3 || !n4 || !n5) return volume;
|
if ( !n1 || !n2 || !n3 || !n4 || !n5) return volume;
|
||||||
CheckMemory();
|
if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if(hasConstructionFaces()) {
|
if(hasConstructionFaces()) {
|
||||||
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
|
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
|
||||||
SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n5);
|
SMDS_MeshFace * f2=FindFaceOrCreate(n1,n2,n5);
|
||||||
@ -620,7 +625,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
|
|||||||
{
|
{
|
||||||
SMDS_MeshVolume* volume = 0;
|
SMDS_MeshVolume* volume = 0;
|
||||||
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6) return volume;
|
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6) return volume;
|
||||||
CheckMemory();
|
if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if(hasConstructionFaces()) {
|
if(hasConstructionFaces()) {
|
||||||
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
|
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3);
|
||||||
SMDS_MeshFace * f2=FindFaceOrCreate(n4,n5,n6);
|
SMDS_MeshFace * f2=FindFaceOrCreate(n4,n5,n6);
|
||||||
@ -722,7 +727,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
|
|||||||
{
|
{
|
||||||
SMDS_MeshVolume* volume = 0;
|
SMDS_MeshVolume* volume = 0;
|
||||||
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6 || !n7 || !n8) return volume;
|
if ( !n1 || !n2 || !n3 || !n4 || !n5 || !n6 || !n7 || !n8) return volume;
|
||||||
CheckMemory();
|
if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if(hasConstructionFaces()) {
|
if(hasConstructionFaces()) {
|
||||||
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
|
SMDS_MeshFace * f1=FindFaceOrCreate(n1,n2,n3,n4);
|
||||||
SMDS_MeshFace * f2=FindFaceOrCreate(n5,n6,n7,n8);
|
SMDS_MeshFace * f2=FindFaceOrCreate(n5,n6,n7,n8);
|
||||||
@ -782,7 +787,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
|
|||||||
if (!hasConstructionFaces())
|
if (!hasConstructionFaces())
|
||||||
return NULL;
|
return NULL;
|
||||||
if ( !f1 || !f2 || !f3 || !f4) return 0;
|
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);
|
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4);
|
||||||
myVolumes.Add(volume);
|
myVolumes.Add(volume);
|
||||||
myInfo.myNbTetras++;
|
myInfo.myNbTetras++;
|
||||||
@ -826,7 +831,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
|
|||||||
if (!hasConstructionFaces())
|
if (!hasConstructionFaces())
|
||||||
return NULL;
|
return NULL;
|
||||||
if ( !f1 || !f2 || !f3 || !f4 || !f5) return 0;
|
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);
|
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5);
|
||||||
myVolumes.Add(volume);
|
myVolumes.Add(volume);
|
||||||
myInfo.myNbPyramids++;
|
myInfo.myNbPyramids++;
|
||||||
@ -872,7 +877,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
|
|||||||
if (!hasConstructionFaces())
|
if (!hasConstructionFaces())
|
||||||
return NULL;
|
return NULL;
|
||||||
if ( !f1 || !f2 || !f3 || !f4 || !f5 || !f6) return 0;
|
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);
|
SMDS_MeshVolume * volume = new SMDS_VolumeOfFaces(f1,f2,f3,f4,f5,f6);
|
||||||
myVolumes.Add(volume);
|
myVolumes.Add(volume);
|
||||||
myInfo.myNbPrisms++;
|
myInfo.myNbPrisms++;
|
||||||
@ -910,7 +915,7 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
|
|||||||
{
|
{
|
||||||
SMDS_MeshFace * face;
|
SMDS_MeshFace * face;
|
||||||
|
|
||||||
CheckMemory();
|
if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if (hasConstructionEdges())
|
if (hasConstructionEdges())
|
||||||
{
|
{
|
||||||
MESSAGE("Error : Not implemented");
|
MESSAGE("Error : Not implemented");
|
||||||
@ -975,7 +980,7 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
|
|||||||
const int ID)
|
const int ID)
|
||||||
{
|
{
|
||||||
SMDS_MeshVolume* volume;
|
SMDS_MeshVolume* volume;
|
||||||
CheckMemory();
|
if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if (hasConstructionFaces()) {
|
if (hasConstructionFaces()) {
|
||||||
MESSAGE("Error : Not implemented");
|
MESSAGE("Error : Not implemented");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1046,7 +1051,7 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1,
|
|||||||
const SMDS_MeshNode * node3)
|
const SMDS_MeshNode * node3)
|
||||||
{
|
{
|
||||||
if ( !node1 || !node2 || !node3) return 0;
|
if ( !node1 || !node2 || !node3) return 0;
|
||||||
CheckMemory();
|
if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if(hasConstructionEdges())
|
if(hasConstructionEdges())
|
||||||
{
|
{
|
||||||
SMDS_MeshEdge *edge1, *edge2, *edge3;
|
SMDS_MeshEdge *edge1, *edge2, *edge3;
|
||||||
@ -1078,7 +1083,7 @@ SMDS_MeshFace * SMDS_Mesh::createQuadrangle(const SMDS_MeshNode * node1,
|
|||||||
const SMDS_MeshNode * node4)
|
const SMDS_MeshNode * node4)
|
||||||
{
|
{
|
||||||
if ( !node1 || !node2 || !node3 || !node4 ) return 0;
|
if ( !node1 || !node2 || !node3 || !node4 ) return 0;
|
||||||
CheckMemory();
|
if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
if(hasConstructionEdges())
|
if(hasConstructionEdges())
|
||||||
{
|
{
|
||||||
SMDS_MeshEdge *edge1, *edge2, *edge3, *edge4;
|
SMDS_MeshEdge *edge1, *edge2, *edge3, *edge4;
|
||||||
@ -1363,7 +1368,7 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1,
|
|||||||
SMDS_MeshEdge * toReturn=NULL;
|
SMDS_MeshEdge * toReturn=NULL;
|
||||||
toReturn=const_cast<SMDS_MeshEdge*>(FindEdge(node1,node2));
|
toReturn=const_cast<SMDS_MeshEdge*>(FindEdge(node1,node2));
|
||||||
if(toReturn==NULL) {
|
if(toReturn==NULL) {
|
||||||
CheckMemory();
|
if ( myEdges.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
|
||||||
toReturn=new SMDS_MeshEdge(node1,node2);
|
toReturn=new SMDS_MeshEdge(node1,node2);
|
||||||
myEdges.Add(toReturn);
|
myEdges.Add(toReturn);
|
||||||
myInfo.myNbEdges++;
|
myInfo.myNbEdges++;
|
||||||
|
Loading…
Reference in New Issue
Block a user