| 1 |
"""Memory watchdog: periodically read the memory usage of the main test process |
| 2 |
and print it out, until terminated.""" |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
import os |
| 9 |
import sys |
| 10 |
import time |
| 11 |
|
| 12 |
|
| 13 |
try: |
| 14 |
page_size = os.sysconf('SC_PAGESIZE') |
| 15 |
except (ValueError, AttributeError): |
| 16 |
try: |
| 17 |
page_size = os.sysconf('SC_PAGE_SIZE') |
| 18 |
except (ValueError, AttributeError): |
| 19 |
page_size = 4096 |
| 20 |
|
| 21 |
while True: |
| 22 |
sys.stdin.seek(0) |
| 23 |
statm = sys.stdin.read() |
| 24 |
data = int(statm.split()[5]) |
| 25 |
sys.stdout.write(" ... process data size: {data:.1f}G\n" |
| 26 |
.format(data=data * page_size / (1024 ** 3))) |
| 27 |
sys.stdout.flush() |
| 28 |
time.sleep(1) |