MCPcopy Create free account
hub / github.com/ActiveState/code / _VmB

Function _VmB

recipes/Python/286222_Memory_usage/recipe-286222.py:8–25  ·  view source on GitHub ↗

Private.

(VmKey)

Source from the content-addressed store, hash-verified

6 'KB': 1024.0, 'MB': 1024.0*1024.0}
7
8def _VmB(VmKey):
9 '''Private.
10 '''
11 global _proc_status, _scale
12 # get pseudo file /proc/<pid>/status
13 try:
14 t = open(_proc_status)
15 v = t.read()
16 t.close()
17 except:
18 return 0.0 # non-Linux?
19 # get VmKey line e.g. 'VmRSS: 9999 kB\n ...'
20 i = v.index(VmKey)
21 v = v[i:].split(None, 3) # whitespace
22 if len(v) < 3:
23 return 0.0 # invalid format?
24 # convert Vm value to bytes
25 return float(v[1]) * _scale[v[2]]
26
27
28def memory(since=0.0):

Callers 3

memoryFunction · 0.85
residentFunction · 0.85
stacksizeFunction · 0.85

Calls 5

openFunction · 0.50
readMethod · 0.45
closeMethod · 0.45
indexMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected