diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index 83da3a26c1..a99cfd7b31 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -610,20 +610,18 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { */ static PyObject * psutil_virtual_mem(PyObject *self, PyObject *args) { - MEMORYSTATUSEX memInfo; - memInfo.dwLength = sizeof(MEMORYSTATUSEX); - - if (! GlobalMemoryStatusEx(&memInfo)) { + PERFORMANCE_INFORMATION perfInfo; + if (! GetPerformanceInfo(&perfInfo, sizeof(PERFORMANCE_INFORMATION))) { PyErr_SetFromWindowsErr(0); return NULL; } return Py_BuildValue("(LLLLLL)", - memInfo.ullTotalPhys, // total - memInfo.ullAvailPhys, // avail - memInfo.ullTotalPageFile, // total page file - memInfo.ullAvailPageFile, // avail page file - memInfo.ullTotalVirtual, // total virtual - memInfo.ullAvailVirtual); // avail virtual + perfInfo.PhysicalTotal * perfInfo.PageSize, // total + perfInfo.PhysicalAvailable * perfInfo.PageSize, // avail + (perfInfo.CommitLimit - perfInfo.PhysicalTotal) * perfInfo.PageSize, // total page file + (perfInfo.CommitLimit - perfInfo.CommitTotal - perfInfo.PhysicalAvailable) * perfInfo.PageSize, // avail page file + perfInfo.CommitLimit * perfInfo.PageSize, // total virtual + (perfInfo.CommitLimit - perfInfo.CommitTotal) * perfInfo.PageSize); // avail virtual }