Cha*_* Ma 13 git perl cygwin memory-management git-svn
我在cygwin中执行git svn rebase时遇到此错误
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.
Run Code Online (Sandbox Code Playgroud)
268439552是256MB.Cygwin的maxium内存大小设置为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;
}
Run Code Online (Sandbox Code Playgroud)
我在第898行之前添加了一个打印来打印$ bytesToRead和$ bytesRead,$ bytesToRead的结果是1024,$ bytesRead的结果是134220800,所以它一次读取1024个字节,它已经读取了128MB.Perl的'read'函数必须是内存不足并试图请求加倍它的内存大小......有没有办法指定要请求多少内存?或者该实现依赖?
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;
}
Run Code Online (Sandbox Code Playgroud)
虽然这个perl程序在文件大小大于384MB时崩溃(但如果文件大小较小则成功).
open(F, "<400") or die("can't read\n");
$size = -s "400";
$read = read(F, $s, $size);
Run Code Online (Sandbox Code Playgroud)
错误类似
Out of memory during "large" request for 536875008 bytes, total sbrk() is 217088 bytes at mem.pl line 6.
Run Code Online (Sandbox Code Playgroud)
这是Gregor Uhlenheuer在最新版msysgit中解决的问题.有补丁可用.问题是在Git.pm中,文件一次性读取.解决方案是以小块读取它.我不确定修复程序是否已进入任何已发布的版本,但修复程序很容易在本地应用.
您需要更改C:\ Program Files\Git\lib\perl5\site_perl\Git.pm(大约8行更改).确保先备份它.
有关操作的详细信息,请参阅Git.pm:在cat_blob()中使用类似流的写入.
最初的讨论是大文件"内存不足"的问题.
你有没有尝试过增加整个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.
这不是特定于Perl的问题,而是与cygwin相关的问题.你可以提高内存分配ulimit.
你使用的是什么版本的git?如果您没有使用最新版本,这可能是使用最新版本修复的低效率(例如,通过一个非常大的文件循环,foreach而不是while谷歌建议我快速搜索时.)
最大化Cygwin内存的解决方案实际上不起作用.
目前Windows上的Git存在两个问题:
我一步一步做了什么:
我将我的git repo移动到Unix机器上,设置下一个配置:
[pack]
threads = 2
packSizeLimit = 2G
windowMemory = 512M
Run Code Online (Sandbox Code Playgroud)
之后,我制作了git gc所有包,并重新制作成2G的包.
双重检查在Windows机器上没有安装MsysGit,可以使用来自MsysGit的perl的其他方式.
将此repo移回Windows机器并提升Cygwin内存限制:
regtool -i set /HKLM/Software/Cygwin/heap_chunk_in_mb 1536
Run Code Online (Sandbox Code Playgroud)
将Cygwin内存设置为高于pack.windowMemory× pack.threads且不高于1.5G非常重要
所以前两个问题现在已经解决了.但第三个不是.
不幸的是,它无法在Windows上运行.在一些重新包装期间,它有时会因内存不足而崩溃.即使使用threads = 1和pack.windowMemory = 16M最大深度和增量设置为250.
| 归档时间: |
|
| 查看次数: |
7374 次 |
| 最近记录: |