summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-03-09 17:18:55 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2019-03-09 17:18:55 -0800
commitb27f621aa9b2b3cd27b00012dc0d293ae5bcd252 (patch)
tree455d11db62712aa93935a512f6a35945b257243b
parentd66df06b6fe5a1fb090d05aa33454ee2af71bcd4 (diff)
downloadpsutil-win-uss-mem.tar.gz
return the original SIZE_T type and multiply for pagesize() in Pythonwin-uss-mem
-rw-r--r--psutil/_psutil_windows.c18
-rw-r--r--psutil/_pswindows.py7
2 files changed, 21 insertions, 4 deletions
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c
index b8e88acc..092b5af2 100644
--- a/psutil/_psutil_windows.c
+++ b/psutil/_psutil_windows.c
@@ -874,10 +874,7 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) {
HeapFree(GetProcessHeap(), 0, wsInfo);
CloseHandle(hProcess);
- // XXX: shall we use GetNativeSystemInfo to get pagesize for
- // WoW64 processes?
- return Py_BuildValue(
- "K", wsCounters.NumberOfPrivatePages * PSUTIL_SYSTEM_INFO.dwPageSize);
+ return Py_BuildValue("I", wsCounters.NumberOfPrivatePages);
}
@@ -3381,6 +3378,17 @@ psutil_sensors_battery(PyObject *self, PyObject *args) {
}
+/*
+ * System memory page size as an int.
+ */
+static PyObject *
+psutil_getpagesize(PyObject *self, PyObject *args) {
+ // XXX: we may want to use GetNativeSystemInfo to differentiate
+ // page size for WoW64 processes (but am not sure).
+ return Py_BuildValue("I", PSUTIL_SYSTEM_INFO.dwPageSize);
+}
+
+
// ------------------------ Python init ---------------------------
static PyMethodDef
@@ -3486,6 +3494,8 @@ PsutilMethods[] = {
"Return CPU frequency."},
{"sensors_battery", psutil_sensors_battery, METH_VARARGS,
"Return battery metrics usage."},
+ {"getpagesize", psutil_getpagesize, METH_VARARGS,
+ "Return system memory page size."},
// --- windows services
{"winservice_enumerate", psutil_winservice_enumerate, METH_VARARGS,
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index 9fa14af4..6687770c 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -36,6 +36,7 @@ from ._common import conn_tmap
from ._common import ENCODING
from ._common import ENCODING_ERRS
from ._common import isfile_strict
+from ._common import memoize
from ._common import memoize_when_activated
from ._common import parse_environ_block
from ._common import sockfam_to_enum
@@ -229,6 +230,11 @@ def py2_strencode(s):
return s.encode(ENCODING, ENCODING_ERRS)
+@memoize
+def getpagesize():
+ return cext.getpagesize()
+
+
# =====================================================================
# --- memory
# =====================================================================
@@ -798,6 +804,7 @@ class Process(object):
def memory_full_info(self):
basic_mem = self.memory_info()
uss = cext.proc_memory_uss(self.pid)
+ uss *= getpagesize()
return pfullmem(*basic_mem + (uss, ))
def memory_maps(self):