title: Understanding output of GHC's +RTS -t -RTS option
body: <p>I'm benchmarking the memory consumption of a haskell programm compiled with GHC. In order to do so, I run the programm with the following command line arguments: <code>+RTS -t -RTS</code>. Here's an example output:
  <code>&lt;&lt;ghc: 86319295256 bytes, 160722 GCs, 53963869/75978648 avg/max bytes residency (386 samples), 191M in use, 0.00 INIT (0.00 elapsed), 152.69 MUT (152.62 elapsed), 58.85 GC (58.82 elapsed) :ghc&gt;&gt;</code>.
  According to the ghc manual, the output shows:</p>
  
  <ul>
  <li>The total number of bytes allocated by the program over the whole run.</li>
  <li>The total number of garbage collections performed.</li>
  <li>The average and maximum "residency", which is the amount of live data in bytes. The runtime can only determine the amount of live data during a major GC, which is why the number of samples corresponds to the number of major GCs (and is usually relatively small).</li>
  <li>The peak memory the RTS has allocated from the OS.</li>
  <li>The amount of CPU time and elapsed wall clock time while initialising the runtime system (INIT), running the program itself (MUT, the mutator), and garbage collecting (GC).</li>
  </ul>
  
  <p>Applied to my example, it means that my program shuffles 82321 MiB (bytes divided by 1024^2) around, performs 160722 garbage collections, has a 51MiB/72MiB average/maximum memory residency, allocates at most 191M memory in RAM and so on ...</p>
  
  <p>Now I want to know, what »The average and maximum "residency", which is the amount of live data in bytes« is compared to »The peak memory the RTS has allocated from the OS«? And also: What uses the remaining space of roughly 120M?</p>
  
  <p>I was pointed <a href="https://www.haskell.org/ghc/docs/latest/html/libraries/base-4.7.0.1/GHC-Stats.html" rel="noreferrer">here</a> for more information, but that does not state clearly, what I want to know. Another <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/prof-heap.html" rel="noreferrer">source</a> (5.4.4 second item) hints that the 120M memory is used for garbage collection. But that is too vague – I need a quotable information source.</p>
  
  <p>So please, is there anyone who could answer my questions with good sources as proofs?</p>
  
  <p>Kind regards!</p>