Guest User

Untitled

a guest
Nov 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. def object_memory():
  2. """ Sum of the size of gc-tracked objects.
  3. Can be useful to summarize, say, the before-and-after difference
  4. of loading in data, building inices, and such.
  5.  
  6. Does NOT reflect the amount of process memory, because it does not count things like:
  7. the interpreter,(~3 MB+?),
  8. interpreter overhead,
  9. libraries,
  10. data stored in C extensions (think numpy and such),
  11. shared memory
  12. ...most of which can be anywhere from next to nothing up to a _lot_.
  13.  
  14. sys.getsizeof() is >=py2.6 (though there are imitations of it for earlier versions)
  15. """
  16. import gc,sys
  17. return sum(sys.getsizeof(o) for o in gc.get_objects())
Add Comment
Please, Sign In to add comment