I found out how to compute a good memory limit for the GHC runtime on Linux systems. One opens /proc/meminfo, and sums the free memory with the reclaimable memory. The memory allocated to file buffers and the disk cache are reclaimable, and can be added to the memory of a growing GHC process. Once you get beyond that memory size, thrashing is in your futures.
I have enclosed a short lex program that computes the limit. It's basically what is done by the procpc program called free, except that I printed only the number of interest to a GHC runtime. John
/* Compute the free memory on a Linux system with /proc/meminfo */ %{ #include <stdio.h> #include <stdlib.h> static int mem_free = 0, buffers = 0, cached = 0; %} DIGITS [0-9]+ SP [ \t]+ %% ^MemFree:{SP}{DIGITS} { mem_free = atoi(yytext + 8); } ^Buffers:{SP}{DIGITS} { buffers = atoi(yytext + 8); } ^Cached:{SP}{DIGITS} { cached = atoi(yytext + 7); } .|\n { } %% int main(void) { const char meminfo[] = "/proc/meminfo"; yyin = fopen(meminfo, "r"); if (!yyin) { fprintf(stderr, "Cannot open %s\n", meminfo); return 1; } int rc = yylex(); if (rc) return rc; printf("%dm\n", (mem_free + buffers + cached) >> 10); return 0; }
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe