Why, when I launch a new process using subprocess.Popen , and request psutil.Process.memory_info(pid) to get the Virtual Memory Size process, I get> 20 megabytes? (in the script that is started using Popen , simple reading and output of stdin. Stdin passes the "script-parent" to it)
main.py
from subprocess import Popen, PIPE, STDOUT import sys, psutil, shlex with Popen(shlex.split('python3 ./test.py'), stdin=PIPE, stdout=PIPE, stderr=STDOUT) as proc: main_stdin = sys.stdin.read() print('Writting main STDIN stream:', main_stdin) proc.stdin.write(bytes(main_stdin, 'UTF-8')) # передаем stdin процессу mem_info = psutil.Process(proc.pid).memory_info() print('RSS:', mem_info.rss/1048576) # байты в Мегабайты print('VMS:', mem_info.vms/1048576) sub_stdout = proc.communicate()[0].decode('UTF-8') print('Reading sub STDOUT: ', sub_stdout) test.py
from sys import stdin print(stdin.read()) Ubuntu 14.04, Python 3.4