[python] Get process reference count and memory usage for memory leak debugging

import psutil, os ,sys
process = psutil.Process(os.getpid())
mem = process.memory_info()[0] / float(2 ** 20)
total_refcount = [ "{} = {}".format(value, sys.getrefcount(value)) for value in globals().values()]
print "memory: {}M\nReference:\n {} ".format(
    mem,
    "\n".join(total_refcount),
)
0
0 Comments
Inline Feedbacks
View all comments