Mon Jan 04 04:09:17 2010: Request 53264 was acted upon. Transaction: Correspondence added by ACALPINI Queue: Win32-Console Subject: Memory leak in _SetStdHandle() in child process Broken in: (no value) Severity: Critical Owner: Nobody Requestors: rcap...@cpan.org Status: new Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=53264 >
1) _SetStdHandle is an internal, undocumented method and should not be used directly. 2) the leak is not in _SetStdHandle, which is a pure wrapper around the Win32 API of the same name. it is instead in the STD_INPUT_HANDLE() constant call. the same behaviour can be observed with constants from other modules: #!perl use warnings; use strict; use Win32::File; use Win32API::File qw(FdGetOsFHandle); TRY: while (1) { my $pid = fork(); # fork() failed. next TRY unless defined $pid; # Parent. if ($pid) { # Wait for child. waitpid($pid, 0); next TRY; } # Child. print READONLY(); exit(0); } I don't know if this is due to the XS constant wrapper, or AUTOLOAD, or what else, but for sure there's something wrong somewhere. as a workaround, use: my $std_input_handle = STD_INPUT_HANDLE(); before the loop, and use $std_input_handle in the child code. cheers, Aldo