I am using 28 files in one perl program.
Each file is about 2Mb in size.
I have taken them into 28 arrays. and printing in 28 output files.
Each output file contains all the arrays concatenated , except current file array.
After 11 output files, each of about 70 MB size,
Out of memory! msg is coming .
How to increase the memory limit.
What I tried is :
I closed each file handler after fetching the data into an array. but no use….
Please suggest solutions.
Assuming that you have four files
A B C D, you then want to create four files so thatFile 1 contains
B C D,File 2 contains
A C D,File 3 contains
A B D, andFile 4 contains
A B C.What you are currently doing is loading every file into an array (just using strings would spare a little memory), and then printing each output file consecutively.
You could also open all output files, then open each input file in sequence and print it to every non-corresponding output file. This keeps only one file in memory at any time.
Memory could be reduced further if you’d say
print {$outhandles[$j]} $_ while <$fh>instead of slurping the input files.Test