Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def object_memory():
- """ Sum of the size of gc-tracked objects.
- Can be useful to summarize, say, the before-and-after difference
- of loading in data, building inices, and such.
- Does NOT reflect the amount of process memory, because it does not count things like:
- the interpreter,(~3 MB+?),
- interpreter overhead,
- libraries,
- data stored in C extensions (think numpy and such),
- shared memory
- ...most of which can be anywhere from next to nothing up to a _lot_.
- sys.getsizeof() is >=py2.6 (though there are imitations of it for earlier versions)
- """
- import gc,sys
- return sum(sys.getsizeof(o) for o in gc.get_objects())
Add Comment
Please, Sign In to add comment