From 3526b81aad9ea335c82bcf97046d58995dd2b464 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 8 Jun 2007 08:53:45 +0000 Subject: [PATCH] NPAL16132 (GHS3D execution failed in Salome version 4.0.0) implement adjustMemory() without calling ghs3d --- src/GHS3DPlugin_GHS3D.cxx | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin_GHS3D.cxx index 52f19e9..2e5ef82 100644 --- a/src/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin_GHS3D.cxx @@ -508,20 +508,30 @@ static bool findLineContaing(const TCollection_AsciiString& theText, static void adjustMemory(int & nbMB, const TCollection_AsciiString & aLogFileName) { - TCollection_AsciiString cmd( "ghs3d -m " ); - cmd += nbMB; - cmd += " 1>"; - cmd += aLogFileName; - - system( cmd.ToCString() ); // run - - // analyse log file - TCollection_AsciiString foundLine; - if ( findLineContaing( "UNABLE TO ALLOCATE MEMORY",aLogFileName,foundLine)) - { + // the second call to ghs3d hangs up until C-d RET typed in terminal, + // if SALOME was launched with args, so we check memory allocation ourself + try { + char* buf = new char[ nbMB * 1024 * 1024 ]; + delete [] buf; + } + catch (...) { nbMB = int( double(nbMB) * 0.75 ); adjustMemory( nbMB, aLogFileName ); } +// TCollection_AsciiString cmd( "ghs3d -m " ); +// cmd += nbMB; +// cmd += " 1>"; +// cmd += aLogFileName; + +// system( cmd.ToCString() ); // run + +// // analyse log file +// TCollection_AsciiString foundLine; +// if ( findLineContaing( "UNABLE TO ALLOCATE MEMORY",aLogFileName,foundLine)) +// { +// nbMB = int( double(nbMB) * 0.75 ); +// adjustMemory( nbMB, aLogFileName ); +// } } //============================================================================= -- 2.39.2