Out of memory with simple Win32 :: Unicode :: File readline loop and Strawberry Perl

The problem I can find 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 happening here is that I am doing a readline, and that continues to have memory until I get an error from memory from Strawberry perl. I use a really large file, but since this code is stream based, it doesn’t matter. Am I missing something here or is there a leak somewhere in Strawberry perl? I tested the exact same code in ActivePerl and there it works fine, i.e. He does not eat memory.

Update: replacing Win32 :: Unicode :: A file with a regular diamond operator seems to work at least on my distribution. 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";}

, , Win32:: Unicode?

+4
2

, , . Win32:: Unicode:: File Path:: Class:: Unicode Unicode. (.. ), , Win32:: Unicode:: File , , . , . , , , . .

+1

$/( $INPUT_RECORD_SEPARATOR) ? $[( () ) 0.

.

BTW: , 3 , Encode:: decode , , readline . !

+1

All Articles