Skip Menu |

This queue is for tickets about the Compress-Bzip2 CPAN distribution.

Report information
The Basics
Id: 102211
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Compress-Bzip2

People
Owner: Nobody in particular
Requestors: RURBAN [...] cpan.org
Cc:
AdminCc:

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



Subject: Memory leak uncompressing big files
Despite our leaktrace tests, this tests shows a big leak: use strict; use Compress::Bzip2 (); use Memory::Usage; my $mu = Memory::Usage->new(); for ( 1 .. 5 ) { my $compress_bzip2_obj = Compress::Bzip2::bzinflateInit( -verbosity => 0 ); my $buf; $mu->record("Before bunzip: $_"); open( my $fh, '<', 'bigfile.bz2' ); while ( read( $fh, $buf, 65335 ) ) { my ( $output, $status ) = $compress_bzip2_obj->bzinflate( \$buf ); } close($fh); $compress_bzip2_obj->bzclose(); $mu->record("After bunzip: $_"); } $mu->dump(); -- Reini Urban
better testcase: t/090-memory-usage.pl: #! perl use strict; use 5.006002; use Compress::Bzip2; use File::Spec; use Memory::Usage; use constant MAX => 25; # MAX times all files in t => 125MB with 75, 15MB with 5, 43MB with 25 use constant MAX_5 => MAX / 5; my $bigfile = File::Spec->catfile('t', '090-tmp-bigfile.bz2'); sub t_compress { warn "Creating $bigfile ...\n"; my $buf; my $mu = Memory::Usage->new(); $mu->record("Before bzopen: $_"); my $bz = Compress::Bzip2::bzopen($bigfile, "w"); for (0 .. MAX) { $mu->record("Before bzwrite: $_") unless $_ % MAX_5; for my $infile (glob "t/*") { next if $infile eq $bigfile; open(my $fh, "<", $infile); while ( read( $fh, $buf, 65335 ) ) { $bz->bzwrite( $buf ); } close $fh; } $mu->record("After bzwrite: $_") unless $_ % MAX_5; } $bz->bzclose; $mu->record("After bzclose: $_"); $mu->dump(); system("bunzip2", "-tv", $bigfile); warn("size: ", -s $bigfile, "\n"); } sub t_uncompress { warn "Uncompressing $bigfile 5x ...\n"; my $buf; my $mu = Memory::Usage->new(); for ( 1 .. 5 ) { my $bz = Compress::Bzip2::bzinflateInit( -verbosity => 0 ); $mu->record("Before bunzip: $_"); open( my $fh, '<', $bigfile ); while ( read( $fh, $buf, 65335 ) ) { my ( $output, $status ) = $bz->bzinflate( \$buf ); } close($fh); $bz->bzclose(); $mu->record("After bunzip: $_"); } $mu->dump(); } t_compress(); t_uncompress(); #unlink $bigfile; Creating t/090-tmp-bigfile.bz2 ... time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff) 0 33872 ( 33872) 8288 ( 8288) 6240 ( 6240) 4204 ( 4204) 2244 ( 2244) Before bzopen: 0 34004 ( 132) 8288 ( 0) 6240 ( 0) 4204 ( 0) 2376 ( 132) Before bzwrite: 0 1 41432 ( 7428) 15700 ( 7412) 6268 ( 28) 4204 ( 0) 9804 ( 7428) After bzwrite: 0 6 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) Before bzwrite: 5 7 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) After bzwrite: 5 12 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) Before bzwrite: 10 14 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) After bzwrite: 10 19 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) Before bzwrite: 15 20 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) After bzwrite: 15 25 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) Before bzwrite: 20 26 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) After bzwrite: 20 31 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) Before bzwrite: 25 32 41432 ( 0) 15700 ( 0) 6268 ( 0) 4204 ( 0) 9804 ( 0) After bzwrite: 25 32 34140 ( -7292) 8476 ( -7224) 6268 ( 0) 4204 ( 0) 2512 ( -7292) After bzclose: t/090-tmp-bigfile.bz2: ok size: 44864471 Uncompressing t/090-tmp-bigfile.bz2 5x ... time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff) 0 34140 ( 34140) 8476 ( 8476) 6268 ( 6268) 4204 ( 4204) 2512 ( 2512) Before bunzip: 1 6 185016 ( 150876) 132972 ( 124496) 6268 ( 0) 4204 ( 0) 153388 ( 150876) After bunzip: 1 6 185016 ( 0) 132972 ( 0) 6268 ( 0) 4204 ( 0) 153388 ( 0) Before bunzip: 2 12 328576 ( 143560) 250700 ( 117728) 6268 ( 0) 4204 ( 0) 296948 ( 143560) After bunzip: 2 12 328576 ( 0) 250700 ( 0) 6268 ( 0) 4204 ( 0) 296948 ( 0) Before bunzip: 3 18 472140 ( 143564) 368444 ( 117744) 6268 ( 0) 4204 ( 0) 440512 ( 143564) After bunzip: 3 18 472140 ( 0) 368444 ( 0) 6268 ( 0) 4204 ( 0) 440512 ( 0) Before bunzip: 4 24 618348 ( 146208) 488564 ( 120120) 6268 ( 0) 4204 ( 0) 586720 ( 146208) After bunzip: 4 24 618348 ( 0) 488564 ( 0) 6268 ( 0) 4204 ( 0) 586720 ( 0) Before bunzip: 5 30 761912 ( 143564) 606308 ( 117744) 6268 ( 0) 4204 ( 0) 730284 ( 143564) After bunzip: 5
RT-Send-CC: nick [...] cpanel.net
Fixed with Release 2.22 Every single XS output buffer leaked, and Test::LeakTrace is not able to detect such XS leaks. -- Reini Urban