2009-12-17 73 views
12

而在Cygwin的做一个混帐SVN变基我得到这个错误为什么Cygwin上的Git.pm会抱怨“大”请求期间内存不足?

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最大内存大小?

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

更新: 这是发生(在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,结果是1024 $ bytesToRead和134220800为$ bytesRead,所以它一次读取1024个字节,它已经读取128MB。 Perl的'读'功能必须是内存不足,并试图请求两倍的内存大小......有没有办法指定要求多少内存?或者那个实现是依赖的?

UPDATE2: 在测试内存分配中的cygwin: 这个C程序的输出为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以上(但成功如果文件大小为少)。

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. 
+1

你确定Cygwin的配置是这里的问题吗? Msys git带有自己的msys perl(通常是'C:\ Program Files \ Git \ bin \ perl.exe')。我不知道Cygwin下会发生什么,但在win32控制台使用下,msysgit使用它的perl而不是我的系统上的其他perls。 – daotoad 2009-12-17 01:26:40

+0

啊是的你是对的,但我的Perl内存测试使用cygwin的Perl版本,它也有这个问题以及 – 2009-12-17 01:41:50

回答

9

这是一个问题,已在最新版本的msysgit中解决了Gregor Uhlenheuer。有一个可用的补丁。问题是,在Git.pm中,文件一次读取。解决方法是以小块读取它。我不确定修补程序是否已发布到任何发布的版本,但修补程序很容易在本地应用。您需要更改C:\ Program Files \ Git \ lib \ perl5 \ site_perl \ Git.pm(约8行更改)。确保你先支持它。

关于做什么的细节,请参阅Git.pm: Use stream-like writing in cat_blob()

原来的讨论是Problems with larger files "Out of memory"

+0

msysgit版本1.8.3中的'/ Git/SVN.pm'似乎仍然存在此错误,我在执行SVN获取到Git repo时发生此错误: “69632'large'请求期间内存不足总共'sbrk()'是在'/ usr/lib/perl5/site_perl/Git/SVN.pm'行1292处的219133952个字节。“ – 2013-07-01 14:19:26

+0

我在使用git-svn克隆SVN回购时仍然遇到这个错误。 Perl中似乎有一些内存限制。每当perl.exe进程获得大约256mb的内存使用量时,在请求X字节期间,获取会因内存不足而死亡,总sbrk()为253132800字节! (git版本1.9.0.msysgit.0) – 2014-05-29 13:55:03

5

这不是一个特定的Perl的问题,而是一个涉及到cygwin的。您可以通过ulimit提高内存分配。

你使用的是什么版本的git?如果你不是最新的版本,这可能是一个效率低下,已被最新版本修复(例如,当我做了一个快速搜索时,谷歌建议使用foreach而不是while来循环播放一个非常大的文件。)

+1

git - 版本给我1.6.5.1.1367.gcd48,我使用最新版本的msysgit http ://code.google.com/p/msysgit/ ulimit输出已经是'unlimited':S – 2009-12-17 00:19:32

+0

是的,我也使用msysgit(版本1.8.3),而不是Cygwin,并且我得到一个类似的错误,但是在在'git svn fetch'中''/ usr/lib/perl5/site_perl/Git/SVN.pm'。 – 2013-07-01 14:30:40

8

你有没有试过增加整个Cygwin的可用内存?

该消息显示Perl已经达到130 MiB(总sbrk()),然后试图请求另一个失败的256MiB。

http://www.perlmonks.org/?node_id=541750

 
By default no Cygwin program can allocate more than 384 MB of memory 
(program+data). You should not need to change this default in most 
circumstances. However, if you need to use more real or virtual 
memory in your machine you may add an entry in the either the 
HKEY_LOCAL_MACHINE (to change the limit for all users) or 
HKEY_CURRENT_USER (for just the current user) section of the registry. 

Add the DWORD value heap_chunk_in_mb and set it to the desired 
memory limit in decimal MB. It is preferred to do this in Cygwin 
using the regtool program included in the Cygwin package. (For 
more information about regtool or the other Cygwin utilities, 
see the Section called Cygwin Utilities in Chapter 3 or use 
each the --help option of each util.) You should always be 
careful when using regtool since damaging your system registry 
can result in an unusable system. 
+0

我按照这些指示来改变内存大小http://www.cygwin.com/cygwin-ug-net/setup-maxmem.html 使用示例程序来测试内存分配显示1536MB,所以它应该是足够的记忆。这让我觉得问题出在perl:S – 2009-12-17 00:38:55

+0

错误表明它没有分配超过384MiB,所以看起来你的改变没有被正确完成。你有a)证实你实际上可以在该手册页中分配1.5GiB和示例程序吗?b)验证在分配384MiB时(而不是在分配超过1.5GiB时)Perl仍然失败?和c)更换后重新启动机器(即使说明不需要)? – 2009-12-17 00:44:55

+0

有趣......我能够在C中使用malloc 1.5GB的内存,但不能在perl中使用384MB的内存malloc – 2009-12-17 01:05:18

5

解决方案最大化Cygwin的记忆里却不起作用。

目前有两个问题使用Git在Windows上:

  1. 包2G以上是很难 通过两种MsysGit和 Cygwin的支持Git的
  2. Cygwin的默认内存 量太小
  3. 32位Git是有问题的

我做了什么一步一步来:

我感动我的git仓库到Unix机器,接着设置CONFIGS:

[pack] 
     threads = 2 
     packSizeLimit = 2G 
     windowMemory = 512M 

之后,我做了git gc,所有包都rebuilded到2G的。

双重检查MsysGit未安装在Windows机器上,其他方式可以使用MsysGit的perl。

迁此回购返回到Windows机器,并提出Cygwin的内存限制:

regtool -i set /HKLM/Software/Cygwin/heap_chunk_in_mb 1536 

这是设置Cygwin的内存高于pack.windowMemory×pack.threads重要,但不高于1.5G

所以前两个问题现在已经解决了。但第三个不是。

不幸的是,它不适用于Windows。在某些重新包装过程中,它有时会因内存不足而崩溃。即使与threads = 1pack.windowMemory = 16M和最大深度和增量设置为250.

相关问题