From a8a3c359241474fdf2bf4a0e55833e6564b3c609 Mon Sep 17 00:00:00 2001 From: rnc Date: Mon, 1 Jul 2013 17:10:33 +0000 Subject: [PATCH] BUG: GHS3DPlugin: Fixed a bug in the max memory computation The default maximum memory was defined as a short integer which caused the maximum memory to be badly initialised on computers with big memory. If the available memory was more than 32768 Mo (2**15 Mo) the max memory was cast from int to short and could be initialised with any value included a negative one. In this case a 20Mo default value was used by GHS3D --- idl/GHS3DPlugin_Algorithm.idl | 8 ++++---- src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx | 16 ++++++++-------- src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx | 16 ++++++++-------- src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx | 8 ++++---- src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx | 8 ++++---- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/idl/GHS3DPlugin_Algorithm.idl b/idl/GHS3DPlugin_Algorithm.idl index af17c87..2a608dd 100644 --- a/idl/GHS3DPlugin_Algorithm.idl +++ b/idl/GHS3DPlugin_Algorithm.idl @@ -76,15 +76,15 @@ module GHS3DPlugin * Maximal size of memory to be used by the algorithm (in Megabytes). * Negative value means not to use this option */ - void SetMaximumMemory(in short MB) raises (SALOME::SALOME_Exception); - short GetMaximumMemory(); + void SetMaximumMemory(in long MB) raises (SALOME::SALOME_Exception); + long GetMaximumMemory(); /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero. * Negative value means not to use this option */ - void SetInitialMemory(in short MB) raises (SALOME::SALOME_Exception); - short GetInitialMemory(); + void SetInitialMemory(in long MB) raises (SALOME::SALOME_Exception); + long GetInitialMemory(); /*! * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium */ diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index 437233c..a5001ae 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -101,7 +101,7 @@ bool GHS3DPlugin_Hypothesis::GetToMeshHoles(bool checkFreeOption) const //function : SetMaximumMemory //======================================================================= -void GHS3DPlugin_Hypothesis::SetMaximumMemory(short MB) +void GHS3DPlugin_Hypothesis::SetMaximumMemory(int MB) { if ( myMaximumMemory != MB ) { myMaximumMemory = MB; @@ -114,7 +114,7 @@ void GHS3DPlugin_Hypothesis::SetMaximumMemory(short MB) // * automatic memory adjustment mode. Default is zero //======================================================================= -short GHS3DPlugin_Hypothesis::GetMaximumMemory() const +int GHS3DPlugin_Hypothesis::GetMaximumMemory() const { return myMaximumMemory; } @@ -123,7 +123,7 @@ short GHS3DPlugin_Hypothesis::GetMaximumMemory() const //function : SetInitialMemory //======================================================================= -void GHS3DPlugin_Hypothesis::SetInitialMemory(short MB) +void GHS3DPlugin_Hypothesis::SetInitialMemory(int MB) { if ( myInitialMemory != MB ) { myInitialMemory = MB; @@ -135,7 +135,7 @@ void GHS3DPlugin_Hypothesis::SetInitialMemory(short MB) //function : GetInitialMemory //======================================================================= -short GHS3DPlugin_Hypothesis::GetInitialMemory() const +int GHS3DPlugin_Hypothesis::GetInitialMemory() const { return myInitialMemory; } @@ -766,7 +766,7 @@ bool GHS3DPlugin_Hypothesis::DefaultMeshHoles() #include #endif -short GHS3DPlugin_Hypothesis::DefaultMaximumMemory() +int GHS3DPlugin_Hypothesis::DefaultMaximumMemory() { #ifndef WIN32 struct sysinfo si; @@ -795,7 +795,7 @@ short GHS3DPlugin_Hypothesis::DefaultMaximumMemory() //function : DefaultInitialMemory //======================================================================= -short GHS3DPlugin_Hypothesis::DefaultInitialMemory() +int GHS3DPlugin_Hypothesis::DefaultInitialMemory() { return DefaultMaximumMemory(); } @@ -1368,7 +1368,7 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h // Default memory is defined at ghs3d installation but it may be not enough, // so allow to use about all available memory if ( m ) { - short aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; + int aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; cmd += " -m "; if ( aMaximumMemory < 0 ) cmd += DefaultMaximumMemory(); @@ -1376,7 +1376,7 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h cmd += aMaximumMemory; } if ( M && !useBndRecovery ) { - short aInitialMemory = hyp ? hyp->myInitialMemory : -1; + int aInitialMemory = hyp ? hyp->myInitialMemory : -1; cmd += " -M "; if ( aInitialMemory > 0 ) cmd += aInitialMemory; diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx index c756104..348b149 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -127,14 +127,14 @@ public: /*! * Maximal size of memory to be used by the algorithm (in Megabytes) */ - void SetMaximumMemory(short MB); - short GetMaximumMemory() const; + void SetMaximumMemory(int MB); + int GetMaximumMemory() const; /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero */ - void SetInitialMemory(short MB); - short GetInitialMemory() const; + void SetInitialMemory(int MB); + int GetInitialMemory() const; /*! * Optimization level: 0-none, 1-light, 2-medium, 3-standard+, 4-strong. Default is medium */ @@ -266,8 +266,8 @@ public: void ClearGroupsToRemove(); static bool DefaultMeshHoles(); - static short DefaultMaximumMemory(); - static short DefaultInitialMemory(); + static int DefaultMaximumMemory(); + static int DefaultInitialMemory(); static short DefaultOptimizationLevel(); static std::string DefaultWorkingDirectory(); static bool DefaultKeepFiles(); @@ -313,8 +313,8 @@ public: private: bool myToMeshHoles; - short myMaximumMemory; - short myInitialMemory; + int myMaximumMemory; + int myInitialMemory; short myOptimizationLevel; bool myKeepFiles; std::string myWorkingDirectory; diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx index bedaf31..7915661 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx @@ -94,7 +94,7 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles() //function : SetMaximumMemory //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB) +void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ) { if ( MB == 0 ) @@ -108,7 +108,7 @@ void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB) //function : GetMaximumMemory //======================================================================= -CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory() +CORBA::Long GHS3DPlugin_Hypothesis_i::GetMaximumMemory() { ASSERT(myBaseImpl); return this->GetImpl()->GetMaximumMemory(); @@ -118,7 +118,7 @@ CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory() //function : SetInitialMemory //======================================================================= -void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB) +void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ) { if ( MB == 0 ) @@ -132,7 +132,7 @@ void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB) //function : GetInitialMemory //======================================================================= -CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory() +CORBA::Long GHS3DPlugin_Hypothesis_i::GetInitialMemory() { ASSERT(myBaseImpl); return this->GetImpl()->GetInitialMemory(); diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx index f3164ad..4ac8b6f 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx @@ -58,14 +58,14 @@ class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: /*! * Maximal size of memory to be used by the algorithm (in Megabytes) */ - void SetMaximumMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); - CORBA::Short GetMaximumMemory(); + void SetMaximumMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ); + CORBA::Long GetMaximumMemory(); /*! * Initial size of memory to be used by the algorithm (in Megabytes) in * automatic memory adjustment mode. Default is zero */ - void SetInitialMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); - CORBA::Short GetInitialMemory(); + void SetInitialMemory(CORBA::Long MB) throw ( SALOME::SALOME_Exception ); + CORBA::Long GetInitialMemory(); /*! * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium */ -- 2.39.2