I wrote one script to read three files and calculate some values after taking some data from that files. The file sizes are ~30Gb, ~25Gb and 1Gb. All the data in these files are tab separated. I am running the program in a double hex core 24 theaded server having 192 Gb ram. Now script is serving the purpose in quite nice time (~ 30 mins) with a memory foot print of <= 7Gb, whereas using top command I can see it is taking ~40Gb. But the problem I am facing is, it is not at all clearing the used memory after execution. I need to run it for several set of files eg (48 sets) even if I want to run in batch process. After 4-5 run I am not getting any of free memory to use. What are the possible ways that can serve me the purpose.
$in1=$ARGV[0]; $in2=$ARGV[1]; $in3=$ARGV[2]; $out1=$ARGV[3]; if (scalar @ARGV != 4){ die " Wrong command\n\n"; } open(OUT,">$outfile"); open (IN1,"$in1"); while (<IN1>){ if ($_ !~ /^\expr/ && $_ !~ /^expr/){ if ($_ =~ /expr/){ if(cond){$some_count++;} } } } close IN1; undef (@_);undef ($_);undef ($in1); $per_reads_aligned = ($reads_aligned/$total_reads)*100; my %hash1 = (); open (IN2,"$in2"); while (<IN2>){ chomp ($_); $hash1{$_} = 1; } $count2=keys(%hash1); close IN2; undef ($in2); undef (@_); undef ($_); open (IN3,"$in3"); while (<IN3>){ if ($_ =~ /expr/){ $var1=$1;$var2=$2;$var3=$3;$var4=$4; if($var1 ne "N" && $var1 ne "S"){ $hhkey1=$var2."_".$var4; if (exists $hash1{$hhkey1}){ $count3++; if($var3 >= 5){$count5++;} if($var3 >= 10){$count6++;} if($var3 >= 15){$count7++;} if($var3 >= 20){$count8++;} } } } } close IN3; undef ($in3); undef (@_); undef ($_); undef (%hash1); ## Some calculation and print to outfile close OUT;
In reply to How to free memory used by previous program? by sourav8888
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |