检测到perl错误“内存不足”glibc-如何修复

检测到perl错误“内存不足”glibc-如何修复,perl,memory,memory-leaks,Perl,Memory,Memory Leaks,我得到一个疯狂的信息: Out of memory! *** glibc detected *** perl: double free or corruption (!prev): 0x00000003f8f89690 *** ======= Backtrace: ========= /lib64/libc.so.6[0x372bc75916] /lib64/libc.so.6[0x372bc78443] /usr/lib64/perl5/CORE/libperl.so(Perl_pregfre

我得到一个疯狂的信息:

Out of memory!
*** glibc detected *** perl: double free or corruption (!prev): 0x00000003f8f89690 ***
======= Backtrace: =========
/lib64/libc.so.6[0x372bc75916]
/lib64/libc.so.6[0x372bc78443]
/usr/lib64/perl5/CORE/libperl.so(Perl_pregfree+0xd1)[0x3c5da74581]
/usr/lib64/perl5/CORE/libperl.so(Perl_op_clear+0xeb)[0x3c5da3829b]
/usr/lib64/perl5/CORE/libperl.so(Perl_op_free+0x15c)[0x3c5da3670c]
/usr/lib64/perl5/CORE/libperl.so(Perl_op_free+0xbc)[0x3c5da3666c]
======= Memory map: ========
00400000-00401000 r-xp 00000000 08:01 2229974                            /usr/bin/perl
00601000-00603000 rw-p 00001000 08:01 2229974                            /usr/bin/perl
0146c000-3f90ce000 rw-p 00000000 00:00 0                                 [heap]
372b800000-372b820000 r-xp 00000000 08:01 4587522                        /lib64/ld-2.12.so
...(alot of these)....
=>> PBS: job killed: vmem 17400672256 exceeded limit 17179869184
当我运行一个脚本时,我已经在50gb的大文件上运行了很多次5-10gb的小文件。我在谷歌上四处搜索,不太明白与这些答案相关的代码问题是什么,所以这里是我的代码:

 my ($ethnicity) = @ARGV;
 my @map;

open ($fh, "<", "/path/$filename")  or die ("Unable to open input file: $!");

open ($fh4, "<", "/path/$filename")     or die ("Unable to open input file: $!");
my @ID = <$fh4>;

open ($fh2, ">", "/path/$filename") or die ("Unable to open output file: $!");
open ($fh3, ">", "/path/$filename") or die ("Unable to open output file: $!");


my $i=0;
my $j=0;

print "The .ped and .map files are being generated\n";

while(  my $line = <$fh> ){
if ($.<3){ 
     $map[$j] = $line;
     $j++;}
else{
    my $temp = $line;
    $temp =~ m/(\d*) (.*)/;
    chomp($temp);
    my $ID = $1;
    print "$ID- ";
    my $geno = $2;
    $geno =~ s /([ATCG])([ATCG])/$1 $2/g;

    $temp = $ID[$i];
    $temp =~ m/(\d*) (1 0 0 [012] [012])/;
    print "$1\n";
    if($ID eq $1){
          print $fh2 "$ID $2 $geno\n"; 
          $i++;}
    else{next;}
    }
}

close $fh;
close $fh2;

我做错了什么?我想我把它编码成逐行查看,然后逐行写入文件以节省内存

您正在将以$fh4打开的整个文件加载到内存中,但没有理由这样做

my $line_from_fh4 = <$fh4>;
my ($id_from_fh4, $rest_from_fh4) = $line_from_fh4 =~ m/(\d*) (1 0 0 [012] [012])/;

while(my $line = <$fh>) {
    if ($.<3) { 
        push @map, $line;
        next;
    }

    chomp($line);

    my ($ID, $geno) = $line =~ m/(\d*) (.*)/;
    $geno =~ s/[ATCG]\K(?=[ATCG])/ /g;

    print "$ID- $id_from_fh4\n";

    if ($ID eq $id_from_fh4){
        print $fh2 "$ID $rest_from_fh4 $geno\n"; 
        $line_from_fh4 = <$fh4>;
        ($id_from_fh4, $rest_from_fh4) = $line_from_fh4 =~ m/(\d*) (1 0 0 [012] [012])/;
    }
}

有什么理由相信吗!当程序的大小超过16GiB时,意味着内存不足?嗯,我真的不这么认为-集群有超过300gb的空间来使用内存RAM,而不是磁盘空间。命令说:unlimitedWell,有东西将进程的大小限制在16GiB,但我不知道是什么。不是我的领域。哇-这减少了很多我的代码:但它不起作用。我厌倦了$fh4仍然是开始读取到整个文件中的这一行::我的$line_from_fh4=;此外,这并不能解释我何时需要它进入下一个geno行,而是停留在$fh4行,直到在标量上下文中出现匹配,就像我的$line_from_fh4=;读取一行,其中一行定义为直到默认情况下遇到第一个换行符。因此,如果你说的是真的,你的文件只有一行,或者你通过更改$/,更改了默认值。这不包括我需要它进入下一个geno行的时间,但是在匹配发生之前,请保持在$fh4行,是的。当匹配发生时,它只进入下一行$fh4。