The issue I have can be found by running the following code in Strawberry perl 5.12.3.0 on Windows XP.
#!/usr/bin/perl -w
use strict;
use warnings;
use Win32::Unicode::File;
use Encode;
my $fname = shift @ARGV;
my $fh = Win32::Unicode::File->new;
if ($fh->open('<', $fname)){
while (my $line = $fh->readline()){}
close $fh;
}else{
print "Couldn't open file: $!\n";
}
The only thing that is happening here is that I perform a readline and this keeps eating memory until I get an Out of memory error from Strawberry perl. I am using a really big file but since this code is stream based it shouldn't matter. Am I missing something here or is there a leak somewhere in Strawberry perl? I tested the exactly same code in ActivePerl and there it works fine, i.e., it doesn't eat memory.
Update: Replacing Win32::Unicode::File with the normal diamond operator seems to work on my distribution at least. See the following code.
use strict;
use warnings;
my $fname = shift @ARGV;
if (open(my $fh, '<', $fname)){
while (my $line = <$fh>){}
close $fh;
}else{ print "Couldn't open file: $!\n";}
So that would suggest the problem lies with Win32::Unicode module right?