Skip Menu |
 

This queue is for tickets about the Switch CPAN distribution.

Report information
The Basics
Id: 45232
Status: new
Priority: 0/
Queue: Switch

People
Owner: Nobody in particular
Requestors: skendric [...] fhcrc.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: memory leak
Date: Wed, 22 Apr 2009 15:25:14 -0700
To: bug-switch [...] rt.cpan.org
From: Stuart Kendrick <skendric [...] fhcrc.org>
Download (untitled) / with headers
text/plain 1.5k
Switch.pm-2.14, perl-5.10.0, CentOS 5.3 i think i've found a memory leak in Switch ============================================================ #!/usr/bin/perl use strict; use warnings; use English; use Perl6::Say; use Switch; $OUTPUT_AUTOFLUSH = 1; my ($count, $file, $line); $file = '/var/log/syslog'; open my $fh, '<', $file or die "Cannot open $file: $!"; while ($line = <$fh>) { $count++; switch ($line) { case /Shrill and clear he crowed/ { say 'shrill' } case /recking nothing of wizardry/ { say 'recking' } } print '.' if $count/10000 == int $count/100000; # Entertain me } say "$file contains $count lines"; ============================================================ The resulting process grows steadily in memory usage, until my OS kills it. i can replace the 'switch' statement as follows, and the process stays constant in memory size and terminates normally ============================================================ #!/usr/bin/perl use strict; use warnings; use English; use Perl6::Say; use Switch; $OUTPUT_AUTOFLUSH = 1; my ($count, $file, $line); $file = '/var/log/syslog'; open my $fh, '<', $file or die "Cannot open $file: $!"; while ($line = <$fh>) { $count++; if ($line =~ /frog/) { say 'Shrill and clear he crowed'; } elsif ($line =~ /toad/) { say 'recking nothing of wizardry'; } print '.' if $count/10000 == int $count/100000; # Entertain me } say "$file contains $count lines"; ============================================================ --sk stuart kendrick fhcrc


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.