Hello,

I have written a perl script which archives (tar + zip) various directories on Windows 2008 R2 64bit. The server has 8GB of memory.

This is how I get all files which need to be archived:

# Get all export and log files and command file to tar it. local *push_files = sub { push(@all_files,$File::Find::name); LOG_MESS +AGE ("### ARCHIVING $File::Find::name\n"); }; # nested sub needed as use warnings complains if not # this from module file::find find(\&push_files, ($par_COMMAND_TXT,$par_EXPORTTOOL_OUTPATH,$par_EXPO +RTTOOL_LOG));

This is how I do the archiving:

my $tar = Archive::Tar->new(); $tar->add_files(@all_files) or die LOG_MESSAGE("!!! Can't run program: + $!\n"); # This is needed for older Perl version => otherwise "COMPRESS_GZIP" B +areword warning no strict; $tar->write( "$ARCHIVE_FILE", COMPRESS_GZIP) or die LOG_MESSAGE("Can't + run program: $!\n"); LOG_MESSAGE ("### Archiving finished");

This works in general fine but when there are to much data to archive (around 1.5 GB) I get the error message: "OUT OF MEMORY" and the script stops. When I check the task manager I can see that this happens when the perl process has around 3.2 GB.I did a test with the windows tool 7zip and this works find and the maximum memory this tool is using is around 140MB.

Now my question: What can I do that I do not get this "out of memory"?
Is there a better way to do the archiving to save memory?

Thanks for your help.
de Michi

In reply to Archive::tar - out of memory - 3,2GB by demichi

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.