Total memory used by Python process?

前端 未结 12 695
眼角桃花
眼角桃花 2020-11-22 04:28

Is there a way for a Python program to determine how much memory it\'s currently using? I\'ve seen discussions about memory usage for a single object, but what I need is tot

12条回答
  •  既然无缘
    2020-11-22 04:53

    Using sh and os to get into python bayer's answer.

    float(sh.awk(sh.ps('u','-p',os.getpid()),'{sum=sum+$6}; END {print sum/1024}'))
    

    Answer is in megabytes.

提交回复
热议问题