1 """Memory watchdog: periodically read the memory usage of the main test process
2 and print it out, until terminated."""
3 # stdin should refer to the process' /proc/<PID>/statm: we don't pass the
4 # process' PID to avoid a race condition in case of - unlikely - PID recycling.
5 # If the process crashes, reading from the /proc entry will fail with ESRCH.
6
7
8 import sys
9 import time
10 from test.support import get_pagesize
11
12
13 while True:
14 page_size = get_pagesize()
15 sys.stdin.seek(0)
16 statm = sys.stdin.read()
17 data = int(statm.split()[5])
18 sys.stdout.write(" ... process data size: {data:.1f}G\n"
19 .format(data=data * page_size / (1024 ** 3)))
20 sys.stdout.flush()
21 time.sleep(1)