Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #14154: Reimplement the bigmem test memory watchdog as a subpro…
…cess.
- Loading branch information
Charles-François Natali
committed
Mar 24, 2012
1 parent
226ed7e
commit 55bce63
Showing
3 changed files
with
38 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Memory watchdog: periodically read the memory usage of the main test process | ||
and print it out, until terminated.""" | ||
# stdin should refer to the process' /proc/<PID>/statm: we don't pass the | ||
# process' PID to avoid a race condition in case of - unlikely - PID recycling. | ||
# If the process crashes, reading from the /proc entry will fail with ESRCH. | ||
|
||
|
||
import os | ||
import sys | ||
import time | ||
|
||
|
||
try: | ||
page_size = os.sysconf('SC_PAGESIZE') | ||
except (ValueError, AttributeError): | ||
try: | ||
page_size = os.sysconf('SC_PAGE_SIZE') | ||
except (ValueError, AttributeError): | ||
page_size = 4096 | ||
|
||
while True: | ||
sys.stdin.seek(0) | ||
statm = sys.stdin.read() | ||
data = int(statm.split()[5]) | ||
sys.stdout.write(" ... process data size: {data:.1f}G\n" | ||
.format(data=data * page_size / (1024 ** 3))) | ||
sys.stdout.flush() | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters