为什么Git.pm on cygwin抱怨“内存不足”的“大”请求? [英] Why does Git.pm on cygwin complain about 'Out of memory during "large" request?

查看:222
本文介绍了为什么Git.pm on cygwin抱怨“内存不足”的“大”请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在cygwin中执行git svn rebase时收到此错误

I'm getting this error while doing a git svn rebase in cygwin

Out of memory during "large" request for 268439552 bytes, total sbrk() is 140652544 bytes at /usr/lib/perl5/site_perl/Git.pm line 898, <GEN1> line 3.

268439552是256MB。 Cygwin的最大内存大小设置为1024MB,所以我猜测它有不同的最大内存大小perl?

268439552 is 256MB. Cygwin's maxium memory size is set to 1024MB so I'm guessing that it has a different maximum memory size for perl?

如何增加perl程序的最大内存大小可以使用?

How can I increase the maximum memory size that perl programs can use?

更新:
这是错误发生的地方(Git.pm):

update: This is where the error occurs (in Git.pm):

 while (1) {
      my $bytesLeft = $size - $bytesRead;
      last unless $bytesLeft;

      my $bytesToRead = $bytesLeft < 1024 ? $bytesLeft : 1024;
      my $read = read($in, $blob, $bytesToRead, $bytesRead); //line 898
      unless (defined($read)) {
         $self->_close_cat_blob();
         throw Error::Simple("in pipe went bad");
      }

      $bytesRead += $read;
   }



我在第898行前添加了一个打印输出$ bytesToRead和$ bytesRead,结果是$ bytesToRead为1024,$ bytesRead为134220800,因此它一次读取1024个字节,它已经读取128MB。 Perl的'read'函数必须是内存不足,并试图请求double它的内存大小...有一种方法来指定请求多少内存?或者是实现依赖的?

I've added a print before line 898 to print out $bytesToRead and $bytesRead and the result was 1024 for $bytesToRead, and 134220800 for $bytesRead, so it's reading 1024 bytes at a time and it has already read 128MB. Perl's 'read' function must be out of memory and is trying to request for double it's memory size...is there a way to specify how much memory to request? or is that implementation dependent?

UPDATE2:
在测试cygwin中的内存分配时:
这个C程序的输出是1536MB

UPDATE2: While testing memory allocation in cygwin: This C program's output was 1536MB

int main() {
   unsigned int bit=0x40000000, sum=0;
   char *x;

   while (bit > 4096) {
      x = malloc(bit);
      if (x)
         sum += bit;
      bit >>= 1;
   }
   printf("%08x bytes (%.1fMb)\n", sum, sum/1024.0/1024.0);
   return 0;
}

虽然这个perl程序崩溃,如果文件大小大于384MB如果文件大小较小)。

While this perl program crashed if the file size is greater than 384MB (but succeeded if the file size was less).

open(F, "<400") or die("can't read\n");
$size = -s "400";

$read = read(F, $s, $size);

错误类似

Out of memory during "large" request for 536875008 bytes, total sbrk() is 217088 bytes at mem.pl line 6.


推荐答案

这是由 Gregor Uhlenheuer 。有一个补丁可用。问题是,在Git.pm,文件是一次读取。解决方案是读取它在小块。

This is a problem that has been solved in the latest version of msysgit by Gregor Uhlenheuer. There is a patch available. The problem is that in Git.pm, the file is read in one go. The solution is to read it in small chunks. I'm not sure if the fix has made it into any released versions, but the fix is easy to apply locally.

您需要更改C:\Program文件\Git\lib\perl5\site_perl\Git.pm(约8行更改)。请务必先备份。

You need to change C:\Program Files\Git\lib\perl5\site_perl\Git.pm (about 8 lines change). Make sure you back it up first.

有关操作的详细信息,请参阅 Git.pm:在cat_blob()中使用流式写作。

For the details of what to do, see Git.pm: Use stream-like writing in cat_blob().

原始讨论是较大文件的问题内存不足

这篇关于为什么Git.pm on cygwin抱怨“内存不足”的“大”请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆