Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from pympler import summary, muppy
import psutil
# source:
def get_virtual_memory_usage_kb(): # pragma: no cover
The process's current virtual memory size in Kb, as a float.
return float(psutil.Process().memory_info_ex().vms) / 1024.0
def memory_usage(where, object_limit=2): # pragma: no cover
Print out a basic summary of memory usage.
mem_summary = summary.summarize(muppy.get_objects())
print("Memory summary:", where)
summary.print_(mem_summary, limit=object_limit)
print("VM: %.2fMb" % (get_virtual_memory_usage_kb() / 1024.0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment