im trying to get the memory usage of the python process itself through a python script with python standard library with win7 64. I searched for a solution and got to : http://fa.bianp.net/blog/2013/different-ways-to-get-memory-consumption-or-lessons-learned-from-memory_profiler/
def memory_usage_ps():
import subprocess
out = subprocess.Popen(['ps', 'v', '-p', str(os.getpid())],
stdout=subprocess.PIPE).communicate()[0].split(b'\n')
vsz_index = out[0].split().index(b'RSS')
mem = float(out[1].split()[vsz_index]) / 1024
return mem
usage of the given function gives me error code:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python27\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\Users\..\Desktop\Script3.py", line 10, in <module>
memory_usage_ps()
File "C:\Users\..\Desktop\Script3.py", line 4, in memory_usage_ps
out = subprocess.Popen(['ps', 'v', '-p', str(os.getpid())], stdout=subprocess.PIPE).communicate()[0].split(b'\n')
File "C:\Program Files (x86)\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Program Files (x86)\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
would appreciate some advice...