kiranvizru / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

get_memory_info() Leaks Handles #166

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run get_memory_info() in a loop

What is the expected output? What do you see instead?

Handles should not increase.

What version of psutil are you using? What Python version?

Python 2.5
psutil 0.2.1 (From download package)

On what operating system? Is it 32bit or 64bit version?

Windows XP 32-bit

Please provide any additional information below.

It seems as though the opened handle in _psutil_mswindows.c:465 never gets 
closed after being used. In other parts of the source the appropriate 
CloseHandle function destroys the handle returned from OpenProcess. In my 
script this causes a lot of problems due to the constant access to 
get_memory_info() and run time.

Original issue reported on code.google.com by codyrpie...@gmail.com on 26 May 2011 at 5:30

GoogleCodeExporter commented 9 years ago
Thanks for the issue report, get_memory_info() was indeed not closing the 
handles opened. Fixed in r977

Original comment by jlo...@gmail.com on 26 May 2011 at 5:42

GoogleCodeExporter commented 9 years ago

Original comment by jlo...@gmail.com on 26 May 2011 at 5:42

GoogleCodeExporter commented 9 years ago

Original comment by jlo...@gmail.com on 26 May 2011 at 5:42

GoogleCodeExporter commented 9 years ago
I noticed there are at least a couple more places where CloseHandle() should be 
called.
I think it would be good to have a test for this (it's not the first report).
Maybe it would make sense to expose a method to determine opened handles on 
Windows.
Not sure whether public or private; is it something that might be desirable?

Original comment by g.rodola on 26 May 2011 at 6:55

GoogleCodeExporter commented 9 years ago
Fine with me if we add a test for it, but I thought we already had memory leak 
testing that should have caught these?

Original comment by jlo...@gmail.com on 26 May 2011 at 6:57

GoogleCodeExporter commented 9 years ago
Handles do not appear as memory usage for a process.

Original comment by wj32...@gmail.com on 27 May 2011 at 8:40

GoogleCodeExporter commented 9 years ago
See r979 and r980.
It seems we are leaking handles somewhere in get_process_ppid().

Original comment by g.rodola on 31 May 2011 at 12:13

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 27 Jun 2011 at 5:52

GoogleCodeExporter commented 9 years ago
The failures were false positives.
Closing this out as fixed.

Original comment by g.rodola on 30 Jun 2011 at 10:22

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 8 Jul 2011 at 7:07

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Updated csets after the SVN -> Mercurial migration:
r977 == revision 401430e49618
r979 == revision 8ecb886ceab7

Original comment by g.rodola on 2 Mar 2013 at 12:00