Windows 上的 Git,“内存不足 - malloc 失败”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10292903/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:28:49  来源:igfitidea点击:

Git on Windows, "Out of memory - malloc failed"

windowsgit

提问by timothyclifford

Have run into a problem with repository and tried almost every possible config setting found out there eg. pack.WindowMemory etc etc

遇到了存储库问题并尝试了几乎所有可能的配置设置,例如。pack.WindowMemory 等

I believe someone has checked in a large file to remote repository and now each time I try and pull or push to it, GIT tries to pack it and runs out of memory:

我相信有人已经将一个大文件签入到远程存储库,现在每次我尝试拉取或推送到它时,GIT 都会尝试打包它并耗尽内存:

Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 6279, done.
Compressing objects: 100% (6147/6147), done.
fatal: Out of memory, malloc failed (tried to allocate 1549040327 bytes)
error: failed to run repack

Have tried git gc& git repackwith various options but keeps returning same error.

尝试了git gcgit repack各种选项,但一直返回相同的错误。

Almost given up and about to just create a new repo but thought I'd ask around first :)

几乎放弃了,准备创建一个新的仓库,但我想我会先问一下:)

回答by git

I found a solution Herethat worked for me.

我在这里找到了一个对我有用的解决方案。

In .git/config file (client and/or server) I added the following:

在 .git/config 文件(客户端和/或服务器)中,我添加了以下内容:

[core]
  packedGitLimit = 128m
  packedGitWindowSize = 128m

[pack]
  deltaCacheSize = 128m
  packSizeLimit = 128m
  windowMemory = 128m

回答by VonC

For reference (you might already seen it), the msysgit case dealing with that issue is the ticket 292.

作为参考(您可能已经看过),处理该问题的 msysgit 案例是票证 292

It suggests several workarounds:

它提出了几种解决方法:

To disable the delta compression for certain files, in .git/info/attributes, add:

要禁用某些文件的增量压缩,请在.git/info/attributes中添加:

*.zip binary -delta

From Gitattributes man page:

Gitattributes 手册页

Delta compression will not be attempted for blobs for paths with the attribute deltaset to false.

对于属性delta设置为 false 的路径,不会尝试对 blob 进行增量压缩。



Maybe a simpler workaround would be to somehow reset the history before that large file commit, and redo the other commits from there.

也许更简单的解决方法是在大文件提交之前以某种方式重置历史记录,并从那里重做其他提交。

回答by olibre

EDIT:  Since git-v2.5.0(Aug/2015), git-for-windows(formerly MSysGit)
      provides 64-bits versionsas noticed by Pan.student.
      In this answer I was advising to install Cygwin64-bits (providing 64-bits Git version).

编辑:自git-v2.5.0 (Aug/2015) 起git-for-windows(以前称为 MSysGit)
      提供了Pan.student所注意到的64 位版本。       在这个答案中,我建议安装 Cygwin64 位(提供 64 位 Git 版本)。



I got a similar Out of memory, malloc failedissue using MSysGitwhen reaching the 4GB barrier:

达到 4GB 时,我在Out of memory, malloc failed使用MSysGit时遇到了类似的问题:

> git --version
git version 1.8.3.msysgit.0

> file path/Git/cmd/git
path/Git/cmd/git: PE32 executable for MS Windows (console) Intel 80386 32-bit

> time git clone --bare -v ssh://linuxhost/path/repo.git
Cloning into bare repository 'repo.git'...
remote: Counting objects: 1664490, done.
remote: Compressing objects: 100% (384843/384843), done.
remote: Total 1664490 (delta 1029586), reused 1664490 (delta 1029586)
Receiving objects: 100% (1664490/1664490), 550.96 MiB | 1.55 MiB/s, done.
Resolving deltas: 100% (1029586/1029586), done.
fatal: Out of memory, malloc failed (tried to allocate 4691583 bytes)
fatal: remote did not send all necessary objects

real    13m8.901s
user    0m0.000s
sys     0m0.015s

MSysGit crashing after reaching 4 GB barrier

MSysGit 在达到 4 GB 障碍后崩溃

Finally git 64 bits from Cygwinfix it:

最后来自Cygwin 的git 64 位修复它:

> git --version
git version 1.7.9

> file /usr/bin/git
/usr/bin/git: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows

> time git clone --bare -v ssh://linuxhost/path/repo.git
Cloning into bare repository 'repo.git'...
remote: Counting objects: 1664490, done.
remote: Compressing objects: 100% (384843/384843), done.
remote: Total 1664490 (delta 1029586), reused 1664490 (delta 1029586)
Receiving objects: 100% (1664490/1664490), 550.96 MiB | 9.19 MiB/s, done.
Resolving deltas: 100% (1029586/1029586), done.

real    13m9.451s
user    3m2.488s
sys     3m53.234s

git 64 bits from Cygwin succeeded

Cygwin 的 git 64 位成功

FYI on linuxhost64 bits:

linuxhost64位仅供参考:

repo.git> git config -l
[email protected]
core.repositoryformatversion=0
core.filemode=true
core.bare=true

repo.git> git --version
git version 1.8.3.4

repo.git> uname -a
Linux linuxhost 2.6.32-279.19.1.el6.x86_64 #1 SMP Sat Nov 24 14:35:28 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

If my answer does not fix your issue, you may also check these pages:

如果我的回答不能解决您的问题,您还可以查看以下页面:

回答by craig Rickett

This worked for me, but I had to set the options via the command line using:

这对我有用,但我必须使用以下命令通过命令行设置选项:

git --global core\pack [param] value