> i am preparing a demonstration on memory management/garbage
> collection,
> and to give the students some real life examples,
> i am looking for a simple patch to some Haskell runtime system
> so that it would display the heap *while* the program is running.
> like, opening an X window and mapping heap cell types to
> pixel colours.
> (i'm prepared to accept horrible slowdowns in program execution)
> i quickly hacked such a display into hugs, just using 3 colours
> (cell is in free list, cell is reachable, cell is unreachable),
> but i'd like to have this for some other (e. g. generational)
> collector as well. any hints appreciated.
This is pretty easy to do in GHC. In fact, just running your program with
'+RTS -Sstderr' will cause it to spew out the residency information on ach
GC. You might want to use a single generation to avoid multiple generations
screwing up the results (i.e. +RTS -G1).
To get more detailed information, you can adapt GHC's heap profiling
mechanisms: there are versions for cost-centre profiling and normal
execution. Contact us for more details.
Cheers,
Simon