In addition to profiling the time and allocation behaviour of your program, you can also generate a graph of its memory usage over time. This is useful for detecting the causes of space leaks, when your program holds on to more memory at run-time that it needs to. Space leaks lead to longer run-times due to heavy garbage collector ativity, and may even cause the program to run out of memory altogether.
To generate a heap profile from your program, compile it as before, but this time run it with the -h runtime option. This generates a file <prog>.hp file, which you then process with hp2ps to produce a Postscript file <prog>.ps. The Postscript file can be viewed with something like ghostview, or printed out on a Postscript-compatible printer.
For the RTS options that control the kind of heap profile generated, see Section 5.5. Details on the usage of the hp2ps program are given in Section 5.6