Before I open a ticket for Archive::Extract, I was wondering if anyone could double-check me.

When using Archive::Extract to extract large gzipped files (.gz), I'm receiving an "Out of Memory" error. (Note: I'm setting $Archive::Extract::PREFER_BIN to 1 to prefer using system binaries.)

Example code:

use Archive::Extract; $Archive::Extract::PREFER_BIN = 1; my $ae = Archive::Extract->new( archive => 'big.txt.gz' ); $ae->extract( to => 'big.txt');

Looking at the module, it looks as if it runs gzip with '-c' (write to STDOUT) and captures the output in a buffer. The buffer is then written to a filehandle. Here's where I need the double-check.

sub _gunzip_bin { my $self = shift; ### check for /bin/gzip -- we need it ### unless( $self->bin_gzip ) { $self->_error(loc("No '%1' program found", '/bin/gzip')); return METHOD_NA; } my $fh = FileHandle->new('>'. $self->_gunzip_to) or return $self->_error(loc("Could not open '%1' for writing: %2" +, $self->_gunzip_to, $! )); my $cmd = [ $self->bin_gzip, '-cdf', $self->archive ]; my $buffer; unless( scalar run( command => $cmd, verbose => $DEBUG, buffer => \$buffer ) ) { return $self->_error(loc("Unable to gunzip '%1': %2", $self->archive, $buffer)); } ### no buffers available? if( !IPC::Cmd->can_capture_buffer and !$buffer ) { $self->_error( $self->_no_buffer_content( $self->archive ) ); } $self->_print($fh, $buffer) if defined $buffer; close $fh; ### set what files where extract, and where they went ### $self->files( [$self->_gunzip_to] ); $self->extract_path( File::Spec->rel2abs(cwd()) ); return 1; }

As far as I can tell, it's not happening with the other methods of compression. It looks like gzipped files are the only ones handled this way.

Thank you!
Casey


In reply to Archive::Extract - Out of Memory by cmilfo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.