Gambit startup: "free memory is now less than 20%..." -- crash
This is most probably for Linux (and UNIX?) only!
A customer has a problem when launching Gambit, gets the following error message:
"LANG en_US.UTF-8 changed temporarily to C for gambit use.
Starting /.../Fluent.Inc/gambit2.3.16/lnamd64/gambit ...
The amount of free memory is now less than 20% of the total system memory (physical + swapspace). This Gambit session may end with a crash.
In that event, there are several possible work-arounds.
1) Try running without other larger processes executing on the same machine.
2) Split your model into several smaller pieces.
3) Running Gambit without the GUI to reduce its memory requirements.
4) Try decreasing the number of levels of UNDO.
5) See if the system administrator can increase either the physical memory
or the swapspace.
6) Try using Mmap by typing something like these lines in the c-shell:
(cannot be used on windows machines)
setenv FLUENT_MMAP_PATH "some path and filename"
setenv FLUENT_USE_MMAP 1
Make sure that the drive has more than enough free disk space.
He uses the 2.3.16 version Gambit on an lnamd64 system.
The same has been rported for 2.4.6.
When he uses free comand, the answer is :
total used free shared buffers cached
Mem: 8165268 6987048 1178220 0 145380 6228804
-/+ buffers/cache: 612864 7552404
Swap: 16024 160 15864
It seems to be less than 20% free but in fact all memory is "cached" and there is no process running (except system process), confirmed by a "top" command.
Apparently, Gambit checks for "free" memory, disregarding the fact that "cached" memory can be counted as "free" because the OS will empty the cache (write its content to the hard disk) and provide the memory, like it had been free, to the application requesting it.
Consequently, to run Gambit, you must once allocate a sufficient amount of memory manually, so that it is taken from the "cached" category, and then make it available for Gambit.
To do that, first compile the attached (see second "Resolution" of this Clarify "Solution") C source code: paste it into a file "lim.c" and issue the command "cc -o lim lim.c".
Next, set some limit:
% limit vmemoryuse 16000m
% ulimit -v 16000000
The number you use should represent about 25% of the physical memory of your machine.
It will count up to the amount of memory allowed by the limit. (If, for some reason, it counts on beyond that value, make sure you abort it as quickly as possible (press <Ctrl-C>).
After these preparations, you should be able to run Gambit!/* lim.c */
struct rlimit rlim;
printf("%s limit:n%20d soft limitn%20d hard limitn",
main(int argc,char **argv)
#define ONE_MEG 1048576
int n = 1;
if (argc > 1)
n = atoi(argv);
if (n < 1 || n > 100000)
n = 1;
size = ONE_MEG*n;
register char *s,*t;
printf("nAllocation Chunk = %d MBn", n);
for(M=0; (s = malloc(size)) != 0; ++M)
for (t = s+size; t > s; t-=1000)
*t = 'x';
printf("nAble to grab %d MBn",M*n);