From: SourceForge.net <no...@so...> - 2008-05-06 17:45:09
|
Bugs item #1958930, was opened at 2008-05-06 19:45 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=1958930&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 24. Channel Commands Group: final: 8.3.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Mark Gammon (mgammon) Assigned to: Andreas Kupries (andreas_kupries) Summary: exec with pipes and fileevents leaks ~2Mb everytime Initial Comment: I'm running Tcl8.3.5 on Windows XP/SP2 & VC8. I think I've seen this reported as a bug before, many years back, but looking at the latest 8.5.2 tclWinPipe.c code it looks like its still there. I need to spawn the same child process 100s of times. After each child process dies a few seconds pass and then it is spawned again. When I do this I see the Virtual Size of the tcl interpreter process slowly growing each time by about 8Mb. With the 2Gb limit for 32bit execs this allows me to make about 250 launches before everything stops. I've cut it down to a simple tcl script that demonstrates a 2Mb leak each time. It would be 4Mb if I attach a pipe to the stderr channel too. ................................................... proc callback {chan fid} { read $fid } pipe in_r in_w pipe out_r out_w fconfigure $out_r -blocking 0 -buffering none set pid [exec ls <@$in_r >@$out_w &] fileevent $out_r readable "callback stdout $out_r" # wait for "ls" to die sleep 1 # MUST force the event loop to be processed update close $in_r close $in_w close $out_r close $out_w ................................................... run the above script repeatedly in the same interpreter session and watch the Virtual Size grow in ProcessExplorer. I've dug down into the code in tclWinPipe.c and I'm pretty sure its happening because of the TerminateThread calls used to kill the pipe read thread. It has to resort to a TerminateThread because the ReadFile call in the read thread is blocked. What I don't quite understand is why it stays blocked even after the child process it is reading from is long dead. I've seen suggestions elsewhere that to get round the blocking problem of ReadFile it should be used in asynchronous mode. This bug is really crippling my app. I'd really like to see a fix for it soon. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=1958930&group_id=10894 |