MCPcopy Index your code
hub / github.com/pythonprofilers/memory_profiler / ps_util_tool

Function ps_util_tool

memory_profiler.py:132–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130 return mem
131
132 def ps_util_tool():
133 # .. cross-platform but but requires psutil ..
134 process = psutil.Process(pid)
135 try:
136 # avoid using get_memory_info since it does not exists
137 # in psutil > 2.0 and accessing it will cause exception.
138 meminfo_attr = 'memory_info' if hasattr(process, 'memory_info') \
139 else 'get_memory_info'
140 mem = getattr(process, meminfo_attr)()[0] / _TWO_20
141 if include_children:
142 mem += sum([mem for (pid, mem) in _get_child_memory(process, meminfo_attr)])
143 if timestamps:
144 return mem, time.time()
145 else:
146 return mem
147 except psutil.AccessDenied:
148 pass
149 # continue and try to get this from ps
150
151 def _ps_util_full_tool(memory_metric):
152

Callers

nothing calls this directly

Calls 1

_get_child_memoryFunction · 0.85

Tested by

no test coverage detected