mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-27 23:30:34 +05:00
use CheckMemory() to avoid crash due to memory allocation problem
This commit is contained in:
parent
b0e0902d31
commit
8d68a5ae9a
@ -292,10 +292,10 @@ void SMESH_VisualObjDef::buildNodePrs()
|
||||
{
|
||||
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
|
||||
// so check remaining memory size for safety
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
vtkPoints* aPoints = vtkPoints::New();
|
||||
createPoints( aPoints );
|
||||
// SMDS_Mesh::CheckMemory();
|
||||
SMDS_Mesh::CheckMemory();
|
||||
myGrid->SetPoints( aPoints );
|
||||
aPoints->Delete();
|
||||
|
||||
@ -358,7 +358,7 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
|
||||
// PAL16631: without swap, bad_alloc is not thrown but hung up and crash instead,
|
||||
// so check remaining memory size for safety
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
|
||||
vtkIdType aCellsSize = 2 * nbEnts[ SMDSAbs_0DElement ] + 3 * nbEnts[ SMDSAbs_Edge ];
|
||||
|
||||
@ -384,13 +384,13 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
vtkCellArray* aConnectivity = vtkCellArray::New();
|
||||
aConnectivity->Allocate( aCellsSize, 0 );
|
||||
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
|
||||
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
|
||||
aCellTypesArray->SetNumberOfComponents( 1 );
|
||||
aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
|
||||
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
|
||||
vtkIdList *anIdList = vtkIdList::New();
|
||||
vtkIdType iElem = 0;
|
||||
@ -398,7 +398,7 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
TConnect aConnect;
|
||||
aConnect.reserve(VTK_CELL_SIZE);
|
||||
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
|
||||
for ( int i = 0; i <= 3; i++ ) // iterate through 0d elements, edges, faces and volumes
|
||||
{
|
||||
@ -501,7 +501,7 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
iElem++;
|
||||
}
|
||||
}
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
}
|
||||
|
||||
// Insert cells in grid
|
||||
@ -510,7 +510,7 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
aCellLocationsArray->SetNumberOfComponents( 1 );
|
||||
aCellLocationsArray->SetNumberOfTuples( aNbCells );
|
||||
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
|
||||
aConnectivity->InitTraversal();
|
||||
for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
|
||||
@ -523,7 +523,7 @@ void SMESH_VisualObjDef::buildElemPrs()
|
||||
aConnectivity->Delete();
|
||||
anIdList->Delete();
|
||||
|
||||
// SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
SMDS_Mesh::CheckMemory(); // PAL16631
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
|
@ -821,6 +821,10 @@ void SMESHGUI_BaseComputeOp::computeMesh()
|
||||
memoryLack = true;
|
||||
}
|
||||
|
||||
if ( !memoryLack && !SMDS_Mesh::CheckMemory(true) ) { // has memory to show dialog boxes?
|
||||
memoryLack = true;
|
||||
}
|
||||
|
||||
// NPAL16631: if ( !memoryLack )
|
||||
{
|
||||
SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
|
||||
@ -830,7 +834,6 @@ void SMESHGUI_BaseComputeOp::computeMesh()
|
||||
// NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
|
||||
SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
|
||||
long newSize = myMesh->NbElements();
|
||||
long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
|
||||
bool limitExceeded;
|
||||
if ( !memoryLack )
|
||||
{
|
||||
@ -856,6 +859,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
|
||||
}
|
||||
else if ( limitExceeded )
|
||||
{
|
||||
long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
|
||||
SUIT_MessageBox::warning( desktop(),
|
||||
tr( "SMESH_WRN_WARNING" ),
|
||||
tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( newSize ).arg( limitSize ) );
|
||||
|
Loading…
Reference in New Issue
Block a user