title: How to return individual memory usage of all objects in memory?
body: <p>How can I see the size (i.e. memory usage) of all objects currently in memory?</p>
  <p>Running the following does not provide correct figures for memory usage</p>
  <pre class="lang-py prettyprint-override"><code>[(m, sys.getsizeof(m)) for m in dir() if not m.startswith('__')]
  
  # Returns
  # ('ElasticNet', 59),
  #  ('ElasticNetCV', 61),
  #  ('In', 51),
  # ...
  </code></pre>
  <p>Whereas for example <code>sys.getsizeof(ElasticNet)</code> shows me that <code>ElasticNet</code> has a size of <code>1064</code>.</p>
  <p>Additionally, is there a convenient tool for assessing which objects are taking up large amounts of RAM, so as to <code>del</code>ete and garbage collect them during the script or session?</p>
  <hr />
  <p>NB <a href="https://stackoverflow.com/questions/938733/total-memory-used-by-python-process">Total memory used by Python process</a> points out how to profile memory at the level of the Python process, whereas I want to determine memory usage for all objects separately, and moreover do so conveniently by retrieving size of the object that <code>m</code> (inside the list comprehension) is referencing.</p>