title: The memory usage reported by guppy differ from ps command
body: <p>I am profiling my twisted server. It uses much more memory than I expected. Its memory usage grows over time.</p>
  
  <pre><code> ps -o pid,rss,vsz,sz,size,command
    PID   RSS    VSZ    SZ    SZ COMMAND
   7697 70856 102176 25544 88320 twistd -y broadcast.tac
  </code></pre>
  
  <p>As you can see it costs <strong>102176 KBs</strong>, namely, <strong>99.78125 MBs</strong>. And I use guppy from a twisted manhole to watch the memory usage profile.</p>
  
  <pre><code>&gt;&gt;&gt; hp.heap()
  Partition of a set of 120537 objects. Total size = 10096636 bytes.
   Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
       0  61145  51  5309736  53   5309736  53 str
       1  27139  23  1031596  10   6341332  63 tuple
       2   2138   2   541328   5   6882660  68 dict (no owner)
       3   7190   6   488920   5   7371580  73 types.CodeType
       4    325   0   436264   4   7807844  77 dict of module
       5   7272   6   407232   4   8215076  81 function
       6    574   0   305776   3   8520852  84 dict of class
       7    605   1   263432   3   8784284  87 type
       8    602   0   237200   2   9021484  89 dict of type
       9    303   0   157560   2   9179044  91 dict of zope.interface.interface.Method
  &lt;384 more rows. Type e.g. '_.more' to view.&gt;
  </code></pre>
  
  <p>Hum... It seems there is something wrong. Guppy shows that the total usage of memory is 10096636 bytes, namely <strong>9859.996 KBs</strong> or <strong>9.628 MBs</strong>.</p>
  
  <p>That's a huge difference. What's wrong this strange result? What am I doing wrong?</p>
  
  <p><strong>Update:</strong>
  I wrote a monitor script last night. It records the memory usage and number of on-line users. It is a radio server, so you can see there is radios and total listeners. Here is the figure I generated by matplotlib.
  <img src="https://web.archive.org/web/20190515063235/http://static.ez2learn.com/temp/mem_figure.svg" alt="alt text"></p>
  
  <p>Something is strange. Sometimes the memory usage printed by ps is very low, like this</p>
  
  <pre><code>2010-01-15 00:46:05,139 INFO 4 4 17904 36732 9183 25944
  2010-01-15 00:47:03,967 INFO 4 4 17916 36732 9183 25944
  2010-01-15 00:48:04,373 INFO 4 4 17916 36732 9183 25944
  2010-01-15 00:49:04,379 INFO 4 4 17916 36732 9183 25944
  2010-01-15 00:50:02,989 INFO 4 4 3700 5256 1314 2260
  </code></pre>
  
  <p>What is the reason of the super low value of memory usage? And what's more, even there is no on-line radios, no listeners, the memory usage is still high.</p>