I'm tasked with locating an apparant memory leak in a legacy app.
hList = ListViewWrapper(hList)
data = hList.Texts()
"data" gets several thousand items every few minutes. I have a separate monitor that measures Win32 handles and the monitor reports that the number of handles increases with time and never goes down. A single execution of "data =" may result in over 150,000 handles being created.
Even if I delete "data" and "hList" immediately after they're created, and then delete the entire class that contains it, the number of handles does not go down. Each new instance of the class causes the number to rise again. After a period of time, the app crashes. It appears to be invisible to gc.DEBUG_LEAK.
Any guidance would be appreciated.
I am looking into this.
Can you tell me which version of pywinauto you are using? (and maybe the revision of controls\common_controls.py and application.py)?
The ideas I have currently are:
- That application.py is storing objects in a history (it used to - but the latest version disables that and it has been disabled for a while)
- Some issue with how I get items from a list view (no concrete ideas yet)
application.py rev 559 7/28/2006
common_controls rev 561 7/28/2006
I am fairly certain that I have found the error...
In the __del__ method of pywinautp\controls\common_controls.py I was not closing the process handle.
Please add the following...
# close the handle to the process
ret = win32functions.CloseHandle(self.process)
if not ret:
After the call to win32functions.VirtualFreeEx(..)
(well after the check of ret after the call!
I used Task Manager to see how many handles I had open - and change solved it for me.
Thanks for the patch. Its working fine now!
Can we have an official fix for this? Downloaded version from the website still says pywinauto-0.3.6. Also doing:
print pywinauto.__version__ returns 0.3.6
Yes - soon now. I am getting a review of something I just checked into a branch.
Once that is approved I should be able to push out a release containing this.
Sorry for the delay.
And it has been release :-)
Log in to post a comment.