diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index a5bdafd37..0ce4e8ffe 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -1599,7 +1599,7 @@ PsutilMethods[] = { {"disk_usage", psutil_disk_usage, METH_VARARGS}, {"getloadavg", (PyCFunction)psutil_get_loadavg, METH_VARARGS}, {"getpagesize", psutil_getpagesize, METH_VARARGS}, - {"getpercentswap", (PyCFunction)psutil_get_percentswap, METH_VARARGS}, + {"getpercentswap", (PyCFunction)psutil_swap_percent, METH_VARARGS}, {"init_loadavg_counter", (PyCFunction)psutil_init_loadavg_counter, METH_VARARGS}, {"net_connections", psutil_net_connections, METH_VARARGS}, {"net_if_addrs", psutil_net_if_addrs, METH_VARARGS}, diff --git a/psutil/arch/windows/wmi.c b/psutil/arch/windows/wmi.c index f4a248163..1ed890f73 100644 --- a/psutil/arch/windows/wmi.c +++ b/psutil/arch/windows/wmi.c @@ -131,7 +131,7 @@ psutil_get_loadavg(PyObject *self, PyObject *args) { * the system. */ PyObject * -psutil_get_percentswap(PyObject *self, PyObject *args) { +psutil_swap_percent(PyObject *self, PyObject *args) { WCHAR *szCounterPath = L"\\Paging File(_Total)\\% Usage"; PDH_STATUS s; HQUERY hQuery; @@ -146,6 +146,7 @@ psutil_get_percentswap(PyObject *self, PyObject *args) { s = PdhAddEnglishCounterW(hQuery, szCounterPath, 0, &hCounter); if (s != ERROR_SUCCESS) { + PdhCloseQuery(hQuery); PyErr_Format( PyExc_RuntimeError, "PdhAddEnglishCounterW failed. Performance counters may be disabled." diff --git a/psutil/arch/windows/wmi.h b/psutil/arch/windows/wmi.h index c93411077..00461a20d 100644 --- a/psutil/arch/windows/wmi.h +++ b/psutil/arch/windows/wmi.h @@ -8,4 +8,4 @@ PyObject* psutil_init_loadavg_counter(); PyObject* psutil_get_loadavg(); -PyObject* psutil_get_percentswap(); +PyObject* psutil_swap_percent();