memory map in ghci

Simon Marlow simonmar@microsoft.com
Fri, 27 Apr 2001 10:17:05 +0100


> I cannot find where it is explained the memory distribution used by
> ghci.
> For example, after     ghci +RTS -M16m -RTS
>                        ...
>                        Prelude> :l XX
>                        ...      (YY.o loaded      ...)
>                        ...      (XX   interpreted ...)
>=20
> do  YY.o, XX  take any of these  16Mb ?
>=20
> Are there any commands in  ghci  to get the memory map?
> It is something like
>   space taken by loaded compiled programs,
>                         interpreted programs,
>               by data,
>   free space for program,
>   free space for data,
>   space for stack.
>=20
> Is the interpreted program treated as data?=20

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.  Object
code is never released or unloaded: if you load a newly compiled version
of the same module, GHCi just allocates more memory for it.  The reason
is that objects in the heap may still have references to the old code,
and trying to detect/prevent this is hard.

Interpreted code lives in the heap, and is garbage collected as normal.

Cheers,
	Simon