mem_profile_old.py 562 B

1234567891011121314151617181920
  1. from pympler import summary, muppy
  2. import psutil
  3. import resource
  4. import os
  5. import sys
  6. def memory_usage_psutil():
  7. # return the memory usage in MB
  8. process = psutil.Process(os.getpid())
  9. mem = process.get_memory_info()[0] / float(2 ** 20)
  10. return mem
  11. def memory_usage_resource():
  12. rusage_denom = 1024.
  13. if sys.platform == 'darwin':
  14. # ... it seems that in OSX the output is different units ...
  15. rusage_denom = rusage_denom * rusage_denom
  16. mem = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / rusage_denom
  17. return mem