NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.64 ">

6.4. Thriftier: producing a program that gobbles less heap space

“I think I have a space leak…” Re-run your program with +RTS -Sstderr, and remove all doubt! (You'll see the heap usage get bigger and bigger…) [Hmmm…this might be even easier with the -G1 RTS option; so… ./a.out +RTS -Sstderr -G1...]

Once again, the profiling facilities (Chapter 5) are the basic tool for demystifying the space behaviour of your program.

Strict functions are good for space usage, as they are for time, as discussed in the previous section. Strict functions get right down to business, rather than filling up the heap with closures (the system's notes to itself about how to evaluate something, should it eventually be required).