
Simon Marlow
ulimit is a good way to catch an infinite loop. But it's not a good way to tell GHC how much memory you want to use - if GHC knows the memory limit, then it can make much more intelligent decisions about how to manage memory.
I'm interpreting this to mean that GHC doesn't know the ulimit limit? It seems to me that GHC should check this, and adjust its heap limit accordingly.
The -M flag causes the GC algorithm to switch from copying (fast but hungry) to compaction (slow but frugal) as the limit approaches.
In absence of any explicit limits, I think a sensible default is to set maximum total memory use to something like 80%-90% of physical RAM. I've yet to see a Haskell program using more than physical RAM without driving performance (of the system, not just the program) into the basement. The downside of using ulimit is that it's a bit complicated, not very portable, and IIRC it's not entirely obvious which option does what. So some good defaults would be nice. -k -- If I haven't seen further, it is by standing in the footprints of giants