Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: tools/multi-process-rss.py

Issue 106973006: Add error handling and /proc/statm count in multi-process-rss.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/multi-process-rss.py
diff --git a/tools/multi-process-rss.py b/tools/multi-process-rss.py
index 0d97fad37b67ea3283beb7b3a68eec4003ec00ed..100d0f759b1c4660de6904b16899aeab30bd00fd 100755
--- a/tools/multi-process-rss.py
+++ b/tools/multi-process-rss.py
@@ -42,7 +42,10 @@ _LOGGER.addHandler(_NullHandler())
def _recursive_get_children(pid):
- children = psutil.Process(pid).get_children()
+ try:
+ children = psutil.Process(pid).get_children()
+ except psutil.error.NoSuchProcess:
+ return []
descendant = []
for child in children:
descendant.append(child.pid)
@@ -78,7 +81,14 @@ def count_pageframes(pids):
pagemap_dct = {}
for pid in pids:
maps = procfs.ProcMaps.load(pid)
- pagemap_dct[pid] = procfs.ProcPagemap.load(pid, maps)
+ if not maps:
+ _LOGGER.warning('/proc/%d/maps not found.' % pid)
+ continue
+ pagemap = procfs.ProcPagemap.load(pid, maps)
+ if not pagemap:
+ _LOGGER.warning('/proc/%d/pagemap not found.' % pid)
+ continue
+ pagemap_dct[pid] = pagemap
for pid, pagemap in pagemap_dct.iteritems():
for vma in pagemap.vma_internals.itervalues():
@@ -88,6 +98,23 @@ def count_pageframes(pids):
return pageframes
+def count_statm(pids):
+ resident = 0
+ shared = 0
+ private = 0
+
+ for pid in pids:
+ statm = procfs.ProcStatm.load(pid)
+ if not statm:
+ _LOGGER.warning('/proc/%d/statm not found.' % pid)
+ continue
+ resident += statm.resident
+ shared += statm.share
+ private += (statm.resident - statm.share)
+
+ return (resident, shared, private)
+
+
def main(argv):
logging_handler = logging.StreamHandler()
logging_handler.setLevel(logging.WARNING)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698