Skip to content

Commit

Permalink
do not expose memory_maps if kernel does not support it (was raising …
Browse files Browse the repository at this point in the history
…NotImplemented exception
  • Loading branch information
giampaolo committed Feb 5, 2016
1 parent 9110f21 commit e4e16ab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,6 @@ I: 751
N: mpderbec
W: https://github.com/mpderbec
I: 660

N: Mozilla Foundation
D: sample code for process USS memory.
9 changes: 2 additions & 7 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,8 @@ def memory_info(self):
[int(x) * PAGESIZE for x in f.readline().split()[:7]]
return pmem(rss, vms, shared, text, lib, data, dirty)

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

@wrap_exceptions
Expand Down Expand Up @@ -1049,13 +1051,6 @@ def get_blocks():
))
return ls

else:
def memory_maps(self):
msg = "couldn't find /proc/%s/smaps; kernel < 2.6.14 or " \
"CONFIG_MMU kernel configuration option is not enabled" \
% self.pid
raise NotImplementedError(msg)

@wrap_exceptions
def cwd(self):
return readlink("%s/%s/cwd" % (self._procfs_path, self.pid))
Expand Down
3 changes: 3 additions & 0 deletions psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ psutil_proc_memory_info_2(PyObject *self, PyObject *args) {

/**
* Returns the USS of the process.
* Reference:
* https://dxr.mozilla.org/mozilla-central/source/xpcom/base/
* nsMemoryReporterManager.cpp
*/
static PyObject *
psutil_proc_memory_uss(PyObject *self, PyObject *args)
Expand Down

0 comments on commit e4e16ab

Please sign in to comment.