heap and code in ghci
S.D.Mechveliani
mechvel@math.botik.ru
Fri, 27 Apr 2001 14:26:17 +0400
To my request
>> I cannot find where it is explained the memory distribution used by
>> ghci.
>> [..]
Simon Marlow writes
> Interpreted code lives in the heap, and is garbage collected as normal.
> Object code is loaded outside the heap. It takes up real memory
> in the process, because the data has to be relocated when it is
> loaded.
> [..]
Let, for example, all the .o modules were prepared, and we
command
ghci ... +RTS -Mxxm -RTS
...
Loading package std ... linking ... done.
Prelude> :l BPrelude
...
and then try to find sum [1..n].
In my experiment
xx = 7 does not allow to load the program,
8, sum [1..66000] yields "Heap exhausted",
10, sum [1..77000] yields 2964538500.
Probably, this xx Mb is for binary program + heap.
ghci loads .o modules, they take some part of xx,
and all the rest is for the heap.
Right?
Thank you in advance for the explanation.
-----------------
Serge Mechveliani
mechvel@botik.ru