Sushant_K has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monk, I am facing an issue with Archive::Tar module(version 1.96). I am trying to use 'Archive::Tar->new()' on one tar.gz file the compressed size of which is 31 MB and if extracted size is 151 MB. I have written a sample small program for this. It works well with perl version 5.8.7 however for perl version 5.20.1 it gives out of memory error. Following is my program-
use Archive::Tar; my $bundle = "C:\\My_Sample.tar.gz"; my $tar_engine = Archive::Tar->new($bundle, 1); if($tar_engine == undef) { print "\nCant get tar object\n"; } else { my @filelist = $tar_engine->list_files(); if(!$tar_engine->extract(@filelist)) { my $ret = 1; print "\nError in extraction.\n"; } } print "\nCompleted Successfully\n";
For perl-5.20.1, it gives out of memory error when Archive::Tar->new() is called. I am trying this out on Windows. Can anyone help me out ? Please let me know you require any more information.
  • Comment on Archive::Tar is working with perl-5.8.7 but giving Out Of Memory error with perl-5.20.1
  • Download Code

Replies are listed 'Best First'.
Re: Archive::Tar is working with perl-5.8.7 but giving Out Of Memory error with perl-5.20.1
by fishmonger (Chaplain) on Mar 28, 2015 at 19:27 UTC

    I have not used Archive::Tar so this may not make any difference but give this adjustment a try to see if it helps.

    if($tar_engine == undef) { print "\nCant get tar object\n"; } else { my @filelist = $tar_engine->extract; if(! @filelist) { my $ret = 1; print "\nError in extraction.\n"; } else { print "\nCompleted Successfully\n"; } }
Re: Archive::Tar is working with perl-5.8.7 but giving Out Of Memory error with perl-5.20.1
by CountZero (Bishop) on Mar 29, 2015 at 17:08 UTC
    The present version of Archive::Tar is 2.04. Perhaps you can try updating it? I don't have a perl v20.1 handy so I cannot test it

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
      Tried with 2.04 version of Archive::Tar, however facing same issue. The program is going out of memory error.
Re: Archive::Tar is working with perl-5.8.7 but giving Out Of Memory error with perl-5.20.1
by afoken (Chancellor) on Mar 30, 2015 at 13:08 UTC
    if($tar_engine == undef)

    Not related to your problem, but that code does not do what you expect it to do. Numeric equal (==) forces numeric context on both sides, so essentially you are comparing $tar_engine with 0. Perl warns you about this problem if you use warnings. You want to use defined($tar_engine) instead of $tar_engine == undef.

    Another problem:

    if(!$tar_engine->extract(@filelist)) { my $ret = 1; print "\nError in extraction.\n"; }

    The scope of my $ret is limited to the block following if. Outside that block, $ret is either not defined at all or its value stays unchanged.

    I suspect that your script runs without strict and warnings, so there may be more hidden errors. Try adding use strict; and use warnings; to the top of your code and fix problems until perl stops whining.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      After further investigation I found that this program run successfully with 64 bit perl. I downloaded .msi files of 32 bit and 64 bit perl of both ActiveState and Strawberry distribution. For 64 bit ActiveState and Strawberry perl this program completes successfully. However for 32 bit ActiveState and Strawberry perl this program gives out of memory error. I think this issue is somehow related with Perl binary rather than Archive::Tar module. Can anyone please help here ?

        I think this issue is somehow related with Perl binary rather than Archive::Tar module. Can anyone please help here ?

        No, the issue is the same, Archive::Tar slurps, needs lots of memory, 64 bit exes have access to more ram than 32 bit exes