aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeongJae Park <sj38.park@gmail.com>2024-03-31 10:14:18 -0700
committerSeongJae Park <sj38.park@gmail.com>2024-03-31 10:14:18 -0700
commit8066415314eae426de32c501916d9b59781f3910 (patch)
tree34101973111b16ccb6e5ced066659451378b9c28
parentb8dbe8c438d2196a12149ac6ab0d6c625731c29d (diff)
downloaddamo-8066415314eae426de32c501916d9b59781f3910.tar.gz
damo_record: Implement a class for memory footprint
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r--damo_record.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/damo_record.py b/damo_record.py
index aaa50a2b..adcc7a84 100644
--- a/damo_record.py
+++ b/damo_record.py
@@ -121,6 +121,28 @@ def poll_target_pids(kdamonds, add_childs):
cleanup_exit(1)
return True
+class MemFootprint:
+ # Refer to 'statm' file part of linux/Documentation/filesystems/proc.rst
+ # for meaning of the fields
+ size = None
+ resident = None
+ shared = None
+ trs = None
+ lrs = None
+ drs = None
+ dt = None
+
+ def __init__(self, pid):
+ with open('/proc/%s/statm' % pid, 'r') as f:
+ fields = [int(x) for x in f.read().split()]
+ self.size = fields[0]
+ self.resident = fields[1]
+ self.shared = fields[2]
+ self.trs = fields[3]
+ self.lrs = fields[4]
+ self.drs = fields[5]
+ self.dt = fields[6]
+
class MemFootprintsSnapshot:
time = None
pid_statms = {}