getrlimit -M

John Meacham john at
Wed Apr 19 18:46:58 EDT 2006

On Wed, Apr 19, 2006 at 01:23:56PM +0200, Ketil Malde wrote:
> >> perhaps if -M is not otherwise set, 'getrlimit(RLIMIT_AS,..)' could be
> >> called and the maximum heap size set to just under that
> Of course, it is commonly set to 'unlimited' anyway.  Perhaps I should
> limit it; OTOH, the value must be less than 2Gb (signed int), which
> will soon be on the small side for a modern workstation.

on 64 bit systems (where long is 64 bits) it is 64 bits. many 32 bit
systems also provide a 'getrlimit64' as part of their long file support
which is also 64 bits so I don't forsee this being a big issue in

> For my programs, I've found that setting -M to 80% of physical tends
> to work well.  Beyond that, I get thrashing and lousy performance.
> (Perhaps programs mmap'ing large files etc can work well beyond
> physical memory?  I'd be interested to hear others' experiences.)

yeah, that is what I do, I actually set my ulimit to be about the same
to keep any individual thing from getting big enough to swap out my X server and
make life unhappy. for the rare app that actually needs > 2G of ram
(ahem... jhc) I can temporarily raise the limit.

it has made things much nicer when I accidentally write a memory bomb in
any language.


John Meacham - ⑆⑆john⑈

More information about the Glasgow-haskell-users mailing list