Is there a way to limit the memory, ghci can have?

前端 未结 2 511
灰色年华
灰色年华 2020-12-16 15:32

I\'m used to debug my code using ghci. Often, something like this happens (not so obvious, of course):

ghci> let f@(_:x) = 0:1:zipWith(+)f x
ghci> leng         


        
2条回答
  •  时光说笑
    2020-12-16 16:12

    A platform independant way to accomplish this is to supply the -M option as on option to the Haskell runtime like this

    ghci +RTS -M1m
    

    see the GHC documentation’s page on how to control the RTS (runtime system) for details.

    The ghci output now looks like:

    >ghci +RTS -M10m
    GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
    Loading package ghc-prim ... linking ... done.
    Loading package integer-gmp ... linking ... done.
    Loading package base ... linking ... done.
    Loading package ffi-1.0 ... linking ... done.
    Prelude> let f@(_:x) = 0:1:zipWith(+)f x
    Prelude> length f
    Heap exhausted;
    Current maximum heap size is 10485760 bytes (10 MB);
    use `+RTS -M' to increase it.
    

提交回复
热议问题