From 56dc8e2ac0789a2c01d4fc6efacf9c0a9e6e4184 Mon Sep 17 00:00:00 2001 From: Anton Gladky Date: Tue, 28 Feb 2023 01:17:57 +0000 Subject: [PATCH] Disable memory-check in SMDS because sysinfo.h is not working Bug-Debian: https://bugs.debian.org/623560 Last-Update: 2011-09-24 on BSD-systems and causes FTBFS. It is better to disable it only on BSD-platforms. Or use http://code.google.com/p/sysinfo-bsd/source/browse/sysinfo.c for them. Gbp-Pq: Name disable_memory_check.patch --- .../salomesmesh/src/SMDS/SMDS_Mesh.cpp | 58 +------------------ 1 file changed, 1 insertion(+), 57 deletions(-) diff --git a/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp b/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp index 3780b4c1..a987e050 100644 --- a/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp +++ b/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp @@ -61,13 +61,6 @@ #include using namespace std; -#ifndef WIN32 -#if !(defined(__MACH__) && defined(__APPLE__)) -#include -#endif -#include -#endif - // number of added entities to check memory after #define CHECKMEMORY_INTERVAL 100000 @@ -85,56 +78,7 @@ int SMDS_Mesh::chunkSize = 1024; int SMDS_Mesh::CheckMemory(const bool doNotRaise) { -#if 0 -#if (defined(__MACH__) && defined(__APPLE__)) - return 1000; -#else -#ifndef WIN32 - struct sysinfo si; - int err = sysinfo( &si ); - if ( err ) - return -1; - - const unsigned long Mbyte = 1024 * 1024; - - static int limit = -1; - if ( limit < 0 ) { - int status = system("SMDS_MemoryLimit"); // it returns lower limit of free RAM - if (status >= 0 ) { - limit = WEXITSTATUS(status); - } - else { - double factor = ( si.totalswap == 0 ) ? 0.1 : 0.2; - limit = int(( factor * si.totalram * si.mem_unit ) / Mbyte ); - } - if ( limit < 20 ) - limit = 20; - else - limit = int ( limit * 1.5 ); - MESSAGE ( "SMDS_Mesh::CheckMemory() memory limit = " << limit << " MB" ); - } - - // compute separately to avoid overflow - int freeMb = - ( si.freeram * si.mem_unit ) / Mbyte + - ( si.freeswap * si.mem_unit ) / Mbyte; - //cout << "freeMb = " << freeMb << " limit = " << limit << endl; - - if ( freeMb > limit ) - return freeMb - limit; - - if ( doNotRaise ) - return 0; - - MESSAGE ("SMDS_Mesh::CheckMemory() throws as free memory too low: " << freeMb <<" MB" ); - throw std::bad_alloc(); -#else - return -1; -#endif -#endif -#else - return 1000; -#endif + return 1000; } /////////////////////////////////////////////////////////////////////////////// -- 2.30.2