6.4. Thriftier: producing a program that gobbles less heap space
Prev | Chapter 6. Advice on: sooner, faster, smaller, thriftier | Next

## 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, Profiling) 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).

Prev | Up | Next
6.3. Smaller: producing a program that is smaller | Home | Chapter 7. GHC Language Features