You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
The following script will consume an increasing amount of memory:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import logging
import psutil
import time
while True:
try:
for pid in psutil.get_pid_list():
m = psutil.Process(pid)
psutil._psmswindows.get_ppid_map()
except Exception as ex:
logging.warning(ex)
finally:
time.sleep(0.01)
What is the expected output?
No memory leaks
What do you see instead?
A memory leak
What version of psutil are you using? What Python version?
hg clone from Tue Nov 26 18:00:55 2013 +0100
changeset: 1690:578f037d6dbb
On what operating system? Is it 32bit or 64bit version?
Windows 7 32 bit
Please provide any additional information below.
The following changeset resolves the problem for me
changeset: 1691:4862f1b232e9
tag: tip
user: Ulrich Klank <[email protected]>
date: Sat Nov 30 00:01:59 2013 +0100
summary: Fix for memory leak in windows version of get_ppid_map
diff -r 578f037d6dbb -r 4862f1b232e9 psutil/_psutil_mswindows.c
--- a/psutil/_psutil_mswindows.c Tue Nov 26 18:00:55 2013 +0100
+++ b/psutil/_psutil_mswindows.c Sat Nov 30 00:01:59 2013 +0100
@@ -2868,14 +2868,22 @@
if (Process32First(handle, &pe)) {
do {
+
pid = Py_BuildValue("I", pe.th32ProcessID);
if (pid == NULL)
goto error;
+
ppid = Py_BuildValue("I", pe.th32ParentProcessID);
if (ppid == NULL)
goto error;
+
if (PyDict_SetItem(py_retdict, pid, ppid))
goto error;
+
+ Py_XDECREF(pid);
+ Py_XDECREF(ppid);
+ pid = NULL;
+ ppid = NULL;
} while (Process32Next(handle, &pe));
}
From [email protected] on November 30, 2013 00:08:36
Original issue: http://code.google.com/p/psutil/issues/detail?id=448
The text was updated successfully, but these errors were encountered: