Subject: | “Out of memory” with simple Win32::Unicode::File readline loop and Strawberry Perl |
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.
Subject: | ExampleCode.pl |
#!/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";
}