Opened 11 years ago

Closed 8 years ago

#2431 defect closed duplicate (duplicate)

_dumbwin32proc leaks process handle

Reported by: bwh Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: teratorn Branch:
Author:

Description

_dumbwin32proc in Twisted 2.4 and in the latest repository version never closes the process handle. The process handle should no longer be needed once the process's exit code has been collected, so I think it should be closed then. However the signalProcess() function needs to be aware of this.

Attachments (1)

twisted-2.4-_dumbwin32proc-fix-leak.patch (1.2 KB) - added by bwh 11 years ago.
patch against Twisted 2.4 to fix this

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by bwh

patch against Twisted 2.4 to fix this

comment:1 Changed 11 years ago by teratorn

Cc: teratorn added

pyHANDLEs will close themselves when they get garbage collected.

But what strikes me as strange is that Process instances aren't getting collected. If the Process gets collected then the handles ought to be collected and closed as well.

I wrote a test program that spawns processes 100 times a second. The spawned procs are very short lived.

The parent process's handle count continues to increase. I let it get to 22,000 before killing it. Memory usage continues to rise as well.

I added a __del__ to _dumbwin32proc.Process but it never gets called. Will investigate further.

comment:2 Changed 11 years ago by Jean-Paul Calderone

FWIW, adding a del method to Process is as likely to prevent Process instances from every getting collected as it is to show you when they do get collected.

gc.get_referrers() might be more useful.

comment:3 in reply to:  1 Changed 11 years ago by bwh

Replying to teratorn:

pyHANDLEs will close themselves when they get garbage collected.

I didn't know that, though I probably should have expected it. However, relying on garbage collection for resources other than memory is inadvisable, isn't it?

comment:4 Changed 8 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

#3893 was a duplicate of this, but no one noticed.

comment:5 Changed 7 years ago by <automation>

Owner: Glyph deleted
Note: See TracTickets for help on using tickets.