【发布时间】:2013-04-20 04:02:54
【问题描述】:
我正在尝试执行一个 perl 脚本,该脚本处理一个小的 12 x 2 文本文件(大约 260 字节)和一个大的 .bedgraph 文件(至少 1.3 MB 大小)。从这两个文件中,脚本会输出一个新的床位图文件。
我已经在其他 3 个 .bedgraph 文件上运行了这个脚本,但我尝试在其余的文件上运行它,进程不断收到 Killed。
perl 脚本在每个 .bedgraph 文件上运行平均需要大约 20 分钟。
我在本地机器上运行 perl 脚本(不是从服务器上)。我使用的是 Linux OS Ubuntu 12.04 系统 64 位 4GB RAM。
为什么我的 perl 脚本执行总是被终止,我该如何解决这个问题?
这是脚本:
# input file handle
open(my $sizes_fh, '<', 'S_lycopersicum_chromosomes.size') or die $!;
# output file handles
open(my $output, '+>', 'tendaysafterbreaker_output.bedgraph') or die $!;
my @array;
while(<$sizes_fh>){
chomp;
my ($chrom1, $size) = split(/\t/, $_);
@array = (0) x $size;
open(my $bedgraph_fh, '<', 'Solanum_lycopersicum_tendaysafterbreaker.bedgraph') or die $!;
while(<$bedgraph_fh>){
chomp;
my ($chrom2, $start, $end, $FPKM) = split(/\t/, $_);
if ($chrom1 eq $chrom2){
for(my $i = $start; $i < $end; $i++){
$array[$i] += $FPKM;
}
}
}
close $bedgraph_fh or warn $!;
my ($last_start, $last_end) = 0;
my $last_value = $array[0];
for (my $i = 1; $i < $#array; $i++){
my $curr_val = $array[$i];
my $curr_pos = $i;
# if the current value is not equal to the last value
if ($curr_val != $last_value){
my $last_value = $curr_val;
print $output "$chrom1\t$last_start\t$last_end\t$last_value\n";
$last_start = $last_end = $curr_pos;
} else {
$last_end = $i;
}
}
}
close $sizes_fh or warn $!;
【问题讨论】:
-
某事正在向进程发送
SIGKILL,可能是内核的OOM 杀手。dmesg会告诉你是否是这种情况。 -
dmesg输出一堆数字,然后在底部显示Out of memory: Kill process 29571 (perl) score 555 or sacriface child和Killed process 29571 (perl) .... -
@cooldood3490,很明显您的脚本内存不足。请发布您的代码和文件示例,以便我们评估如何解决此问题。
-
@cooldood3490,上面提到的每个文件有多大?
@array失败时包含多少个元素? -
@dan1111
.size文件只有几个 KB,但.bedgraph输入文件句柄的大小至少为 1.6 MB。我认为@array包含的元素最多约为4M。最小的是1M左右。
标签: linux perl memory process kill