When playing with various algorithms in Haskell it often happens to me that I create a program with a memory leak, as it often happens with lazy evaluation. The program taking all the memory isn't really fun, I often have difficulty killing it if I realize it too late.
When using GHC6 I simply had export GHCRTS='-M384m'
in my .bashrc
. But in GHC7 they added a security measure that unless a program is compiled with -rtsopts
, it simply fails when it is given any RTS option either on a command line argument or in GHCRTS
. Unfortunately, almost no Haskell programs are compiled with this flag, so setting this variable makes everything to fail (as I discovered in After upgrading to GHC7, all programs suddenly fail saying "Most RTS options are disabled. Link with -rtsopts to enable them.").
Any ideas how to make any use of GHCRTS
with GHC7, or another convenient way how to prevent my programs taking all memory?
-rtsopts
for a program you know to be memory-critical?-M384M
option by default for his own programs using theGHCRTS
environment variable, but now he can't do it because other Haskell tools (such as, perhaps,cabal-dev
) will fail when given anRTS
parameter.ulimit -m
to limit the amount of memory processes started from a shell can take. Other *nixes probably have some variation on theulimit
switches they accept.-m
does the trick? I always use-v
. But I don't really understand that *nix slang or what it is, "maximum resident set size"...