Skip to content

Commit e4e16ab

Browse files
committed
do not expose memory_maps if kernel does not support it (was raising NotImplemented exception
1 parent 9110f21 commit e4e16ab

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

CREDITS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,3 +375,6 @@ I: 751
375375
N: mpderbec
376376
W: https://github.com/mpderbec
377377
I: 660
378+
379+
N: Mozilla Foundation
380+
D: sample code for process USS memory.

psutil/_pslinux.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,8 @@ def memory_info(self):
970970
[int(x) * PAGESIZE for x in f.readline().split()[:7]]
971971
return pmem(rss, vms, shared, text, lib, data, dirty)
972972

973+
# /proc/pid/smaps does not exist on kernels < 2.6.14 or if
974+
# CONFIG_MMU kernel configuration option is not enabled.
973975
if HAS_SMAPS:
974976

975977
@wrap_exceptions
@@ -1049,13 +1051,6 @@ def get_blocks():
10491051
))
10501052
return ls
10511053

1052-
else:
1053-
def memory_maps(self):
1054-
msg = "couldn't find /proc/%s/smaps; kernel < 2.6.14 or " \
1055-
"CONFIG_MMU kernel configuration option is not enabled" \
1056-
% self.pid
1057-
raise NotImplementedError(msg)
1058-
10591054
@wrap_exceptions
10601055
def cwd(self):
10611056
return readlink("%s/%s/cwd" % (self._procfs_path, self.pid))

psutil/_psutil_windows.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ psutil_proc_memory_info_2(PyObject *self, PyObject *args) {
801801

802802
/**
803803
* Returns the USS of the process.
804+
* Reference:
805+
* https://dxr.mozilla.org/mozilla-central/source/xpcom/base/
806+
* nsMemoryReporterManager.cpp
804807
*/
805808
static PyObject *
806809
psutil_proc_memory_uss(PyObject *self, PyObject *args)

0 commit comments

Comments
 (0)