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

tim*_*ord 66 windows git

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

我相信有人已经检查了一个大文件到远程存储库,现在每次我尝试拉动或推送它时,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
Run Code Online (Sandbox Code Playgroud)

尝试过各种选项的git gc&git repack,但仍然返回相同的错误.

几乎放弃了,即将创建一个新的回购,但我想先问一下:)

小智 101

我找到了一个解决方案,对我有用.

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

[core]
  packedGitLimit = 128m
  packedGitWindowSize = 128m

[pack]
  deltaCacheSize = 128m
  packSizeLimit = 128m
  windowMemory = 128m
Run Code Online (Sandbox Code Playgroud)

  • 如果在 64 位机器上运行,msysgit 似乎不会使用 32 位的正确默认值。然而它应该是这样的,因为客户端是 32 位的。这些值对我有用: [core] PackedGitLimit = 256m PackedGitWindowSize = 32m [pack] deltaCacheSize = 256m packSizeLimit = 1g windowMemory = 256m (2认同)

Von*_*onC 18

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

它提出了几个解决方法:

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

*.zip binary -delta
Run Code Online (Sandbox Code Playgroud)

Gitattributes手册页:

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


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


oli*_*bre 14

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


当达到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
Run Code Online (Sandbox Code Playgroud)

MSysGit在达到4 GB屏障后崩溃

最后来自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
Run Code Online (Sandbox Code Playgroud)

来自Cygwin的git 64位成功了

linuxhost64位的FYI :

repo.git> git config -l
user.email=name@company.com
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
Run Code Online (Sandbox Code Playgroud)

如果我的回答无法解决您的问题,您也可以查看以下页面:


归档时间:

查看次数:

73013 次

最近记录:

9 年,2 月 前