2006-11-16 13:09:07 +01:00
|
|
|
import proc, proc_smaps
|
|
|
|
|
|
|
|
class Analysis:
|
2006-12-04 20:12:24 +01:00
|
|
|
|
|
|
|
pid = 0
|
|
|
|
|
|
|
|
def __init__(self, pid):
|
|
|
|
self.pid = pid
|
|
|
|
|
2007-08-08 00:14:19 +02:00
|
|
|
def SMaps(self):
|
2006-12-04 20:12:24 +01:00
|
|
|
smaps = proc_smaps.ProcSmaps(self.pid)
|
2007-08-08 00:14:19 +02:00
|
|
|
private_dirty = 0
|
|
|
|
shared_dirty = 0
|
|
|
|
referenced = 0
|
2006-11-16 13:09:07 +01:00
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
for map in smaps.mappings:
|
2007-08-08 00:14:19 +02:00
|
|
|
private_dirty += map.private_dirty
|
|
|
|
shared_dirty += map.shared_dirty
|
|
|
|
referenced += map.referenced
|
2006-11-16 13:09:07 +01:00
|
|
|
|
2007-08-08 00:14:19 +02:00
|
|
|
smaps = {"private_dirty": int(private_dirty), \
|
|
|
|
"shared_dirty": int(shared_dirty),\
|
|
|
|
"referenced": int(referenced)}
|
2006-11-16 13:09:07 +01:00
|
|
|
|
2007-08-08 00:14:19 +02:00
|
|
|
return smaps
|
2006-12-04 20:12:24 +01:00
|
|
|
|
|
|
|
def ApproxRealMemoryUsage(self):
|
|
|
|
maps = proc_smaps.ProcMaps(self.pid)
|
|
|
|
size = (maps.clean_size/1024)
|
2006-11-16 13:09:07 +01:00
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
return size
|
|
|
|
|