In a recent question about stack overflows in Haskell kosmikus said the default stack size of GHCi is 512 MB. I would much rather have a smaller stack size, like 2 MB or something, because if I go beyond that, in almost all cases, it will be because of an error on my part. My system doesn't have very much RAM, so a stack size of 512 MB sometimes causes some crazy swapping and slowness when I make a mistake in the code.

Is there a way to limit the default stack size of GHCi, in the .ghci file or somewhere else?

I'm aware that I should be able to create an

alias ghci='ghci +RTS -K2M -RTS'

as a last resort, but I'd like to avoid that if possible.

share|improve this question
1  
I think the alias is probably not a bad option if you really want that. Note that the ghci binary is actually the same as the ghc binary, and limiting its stack size means you're limiting the stack size during compilation as well. Setting it to a really small value can yield errors coming from the compilation. For example, running ghci +RTS -K1K immediately crashes. – kosmikus Dec 1 '13 at 16:09
1  
Possible duplicate: stackoverflow.com/questions/19950074/… – Mikhail Glushenkov Dec 1 '13 at 16:20
    
@MikhailGlushenkov Not this time! I don't want to do this for every program, I want it to be the default for all programs. – kqr Dec 1 '13 at 16:52
    
@kqr My understanding is that you need to find a way to modify RtsFlags.GcFlags.maxStkSize from a running Haskell program to be able to set stack size from .ghci. Which is the same as the linked question. – Mikhail Glushenkov Dec 1 '13 at 17:57
    
@MikhailGlushenkov Oh, clever workaround. I'll look into it. – kqr Dec 1 '13 at 18:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.