1 // File : SMDS_MemoryLimit.cxx
2 // Created : Fri Sep 21 17:16:42 2007
3 // Author : Edward AGAPOV (eap)
5 // Executable to find out a lower RAM limit (MB), i.e. at what size of freeRAM
6 // reported by sysinfo, no more memory can be allocated.
7 // This is not done inside a function of SALOME because allocated memory is not returned
8 // to the system. (PAL16631)
11 #include <sys/sysinfo.h>
18 int main (int argc, char ** argv)
20 // To better understand what is going on here, consult bug [SALOME platform 0019911]
23 int err = sysinfo( &si );
26 unsigned long freeRamKb = ( si.freeram * si.mem_unit ) / 1024;
28 // totat RAM size in Gb, float is in order not to have 1 instead of 1.9
29 float totalramGb = float( si.totalram * si.mem_unit ) / 1024 / 1024 / 1024;
31 // nb Kbites to allocate at one step. Small nb leads to hung up
32 const int stepKb = int( 5 * totalramGb );
34 unsigned long nbSteps = freeRamKb / stepKb * 2;
37 new char[stepKb*1024];
40 freeRamKb = ( si.freeram * si.mem_unit ) / 1024;
45 // std::cout << freeRamKb / 1024 << std::endl;
47 return freeRamKb / 1024;