Memory usage under -O2

Simon Marlow simonmar@microsoft.com
Mon, 13 Aug 2001 09:56:10 +0100


> Heap usage after compiling my program with -O is vastly
> different (at least 10x more) than without -O.  Why?  How
> can I prevent this?  (other than, of course, not using -O)

One possible cause of this is the full-laziness (or
almost-full-laziness) transformation that GHC performs when -O is on.
If you're up to reading core, then -ddump-simpl or -dverbose-core2core
might help you figure out what's going on, after you've narrowed down
the culprit with heap profiling.

Unfortunately we don't have a way to turn off full-laziness at the
moment, aside from patching the compiler.  The optimisation pass
ordering is specified in main/DriverState.hs, in the function
'buildCoreToDo'.

Cheers,
	Simon