安装python多少内存_Python进程使用的全部内存?

在Windows上,您可以使用WMI(主页, 芝士店):def memory():

import os    from wmi import WMI

w = WMI('.')

result = w.query("SELECT WorkingSet FROM Win32_PerfRawData_PerfProc_Process WHERE IDProcess=%d" % os.getpid())

return int(result[0].WorkingSet)import os

_proc_status = '/proc/%d/status' % os.getpid()_scale = {'kB': 1024.0, 'mB': 1024.0*1024.0,

'KB': 1024.0, 'MB': 1024.0*1024.0}def _VmB(VmKey):

'''Private.

'''

global _proc_status, _scale     # get pseudo file  /proc//status

try:

t = open(_proc_status)

v = t.read()

t.close()

except:

return 0.0  # non-Linux?

# get VmKey line e.g. 'VmRSS:  9999  kB\n ...'

i = v.index(VmKey)

v = v[i:].split(None, 3)  # whitespace

if len(v) 

return 0.0  # invalid format?

# convert Vm value to bytes

return float(v[1]) * _scale[v[2]]def memory(since=0.0):

'''Return memory usage in bytes.

'''

return _VmB('VmSize:') - sincedef resident(since=0.0):

'''Return resident memory usage in bytes.

'''

return _VmB('VmRSS:') - sincedef stacksize(since=0.0):

'''Return stack size in bytes.

'''

return _VmB('VmStk:') - since

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值