【问题标题】:git fetch: Cannot allocate memorygit fetch:无法分配内存
【发布时间】:2013-12-18 08:15:08
【问题描述】:
  1. 首先我要做:git submodule update --init
克隆到 '_aaa'... 检查连接...完成。 子模块路径'_aaa':签出'87311dd0bb0ac9b77cd9bbac0a15671858f0cf17'
  1. 然后:git fetch --recurse-submodules
获取子模块 _base 获取子模块 _aaa 自动打包存储库以获得最佳性能。你也可以 手动运行“git gc”。有关更多信息,请参阅“git help gc”。 计数对象:21678,完成。 压缩对象:100% (20602/20602),完成。 写入对象:100% (21678/21678),完成。 总计 21678(增量 8973),重复使用 0(增量 0) 删除重复对象:100% (256/256),完成。 致命:内存不足? mmap 失败:无法分配内存 致命:内存不足? mmap 失败:无法分配内存 错误:未能运行修剪

上次更新非常大,大约 1GB,但没有超过 40MB 的文件。

我将服务器上的内存量从 512M 增加到 1024M,但问题仍然存在。我也尝试了git gc、window、compress等不同的玩法,没有任何结果。

【问题讨论】:

  • 作为替代解决方案,您可以一次获取一个子模块,而不是使用--recurse-submodules
  • 我已经试过了,同样的错误。
  • 你看过这个问题了吗? stackoverflow.com/q/6775242/1248175
  • 当然,但据我了解,它们有不同的情况,例如:git fetch --work 和大文件我没有和 git 版本 1.8.4.1。

标签: git


【解决方案1】:

错误本身源于 git 的 sha1 对象处理代码,但如果不知道mmap 返回的errno 是什么,就很难说到底发生了什么。

您能否在strace 下运行您的命令并在此处发布有关 mmap 失败的行?

编辑:试试git config --add core.bigFileThreshold 4m(或者更小的数字)。

core.bigFileThreshold

    Files larger than this size are stored deflated, without attempting delta compression. Storing large files without delta compression avoids excessive memory usage, at the slight expense of increased disk usage.

    Default is 512 MiB on all platforms. This should be reasonable for most projects as source code and other text files can still be delta compressed, but larger binary media files won’t be.

    Common unit suffixes of k, m, or g are supported.

https://www.kernel.org/pub/software/scm/git/docs/git-config.html

【讨论】:

  • 这里是第一个收入
     ... [pid 23816] fcntl(3, F_SETFD, FD_CLOEXEC) = 0 [pid 23816] read(3, "PACK\0\0\0 \2\0\0T\256", 12) = 12 [pid 23816] lseek(3, 918541449, SEEK_SET) = 918541449 [pid 23816] 读取(3, "n\373\t\n\341\330Tf\253 \372\263/\211e%\f8\5Y(", 20) = 20 [pid 23816] mmap(NULL, 918541469, PROT_READ, MAP_PRIVATE, 3, 0) = -1 ENOMEM (无法分配内存) [pid 23816] mmap(NULL, 918541469, PROT_READ, MAP_PRIVATE, 3, 0) = -1 ENOMEM (无法分配内存) [pid 23816] write(2, "fatal: Out of memory? mmap faile"..., 58) = 58 [ pid 23816] exit_group(128) = ? 
  • 有趣。我没有明确的答案,它只是看起来显然内存不足。难道你只有一个巨大的“/idol/.client/.git/modules/_aaa/packed-refs”文件?它只是一个文本文件来加速 git 查找 - 而不是在文件系统中查找对象。另外,你说你玩过 ​​git gc - 你试过git gc --aggressive --prune=now吗?
  • git gc --aggressive --prune=now 计数对象:118,完成。压缩对象:100% (115/115),完成。书写对象:100% (118/118),完成。总计 118 个(增量 48),重复使用 70 个(增量 0)
  • git fetch --recurse-submodules 获取子模块 _base 获取子模块 _aaa 致命:内存不足? mmap 失败:无法分配内存
  • /idol/.client/.git/modules/_aaa/packed-refs #pack-refs with: 去皮全去皮 2fa2b7ba4de47bf0867732cf345e662bc654c96f refs/heads/master 2fa2b7ba4de47bf0867732cf345e662bc跨度>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-26
  • 2015-05-17
  • 2017-07-15
  • 2015-08-15
  • 2015-04-01
  • 2017-12-05
相关资源
最近更新 更多