Git 克隆因内存不足错误而失败 - “致命:内存不足,malloc 失败(试图分配 905574791 字节)/致命:索引包失败”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7607970/
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
Git clone fails with out of memory error - "fatal: out of memory, malloc failed (tried to allocate 905574791 bytes) / fatal: index-pack failed"
提问by grw
I'm attempting to clone a large (1.4GB) Git repository to a 32-bit Debian VM with 384MB of RAM. I'm using Git 1.7.2.5, and using the SSH protocol to clone ('git clone [email protected]:/my/repo')
我正在尝试将大型(1.4GB)Git 存储库克隆到具有 384MB RAM 的 32 位 Debian VM。我正在使用 Git 1.7.2.5,并使用 SSH 协议进行克隆('git clone [email protected]:/my/repo')
The clone fails with this message:
克隆失败并显示以下消息:
remote: Counting objects: 18797, done.
remote: warning: subobtimal pack - out of memory
remote: Compressing objects: 100% (10363/10363), done.
fatal: out of memory, malloc failed (tried to allocate 905574791 bytes)
fatal: index-pack failed
I've tried reducing the amount of memory Git uses to repack on the host repository end, and repacking:
我尝试减少 Git 用于在主机存储库端重新打包的内存量,并重新打包:
git config pack.windowMemory 10m
git config pack.packSizeLimit 20m
git repack -a -d
My questions are as follows:
我的问题如下:
- Is this a client-size (clone-side) problem or should it be resolved in the repo that I'm cloning from?
In either case, is there anything I can do to make the clone succeed? A lot of the potential solutions online involve some/all of the following things, none of which are acceptable in this instance:
- changing the contents of the repository substantively (i.e. deleting large files)
- giving the VM which is doing the clone more RAM
- giving the VM which is doing the clone a 64-bit virtual CPU
- transferring out-of-band (e.g. using Rsync or SFTP to transfer the .git directory)
- 这是客户端大小(克隆端)问题还是应该在我克隆的存储库中解决?
无论哪种情况,我都可以做些什么来使克隆成功?许多潜在的在线解决方案涉及以下部分/全部内容,在这种情况下,这些都是不可接受的:
- 实质性地改变存储库的内容(即删除大文件)
- 为正在执行克隆的 VM 提供更多 RAM
- 为正在执行克隆的 VM 提供 64 位虚拟 CPU
- 带外传输(例如使用 Rsync 或 SFTP 传输 .git 目录)
Thanks in advance.
提前致谢。
回答by Romain
git clone
will not look at your pack.packSizeLimit
setting, it'll anyway transfer everything in a single pack - unless it changed since the last time I looked.
git clone
不会查看您的pack.packSizeLimit
设置,它无论如何都会将所有内容传输到一个包中 - 除非自我上次查看以来它发生了变化。
Using SCP or Rsync might be a way to work around your issue indeed. Removing the "useless" large files, then repacking the repository you try to clone could also help.
使用 SCP 或 Rsync 可能确实是解决您问题的一种方法。删除“无用”的大文件,然后重新打包您尝试克隆的存储库也可能有所帮助。
Giving more RAM to the VM might also help - I don't think you'll need a 64-bits address space to allocate 900MB... You could also give it enough SWAP space to handle the 900MB package instead of increasing the RAM.
为 VM 提供更多 RAM 也可能有所帮助 - 我认为您不需要 64 位地址空间来分配 900MB...您也可以为其提供足够的 SWAP 空间来处理 900MB 包,而不是增加 RAM。
回答by olibre
I got a similar issue on Windows using MSysGit32 bits. The git 64 bits from Cygwindid the job. Maybe you should use a 64 bits Debian VM (instead of 32 bits one).
我在使用MSysGit32 位的Windows 上遇到了类似的问题。Cygwin的 git 64 位完成了这项工作。也许您应该使用 64 位 Debian VM(而不是 32 位)。
My original answeris available on question Git on Windows, “Out of memory - malloc failed”.
我的原始答案可在Windows上的Git问题“内存不足 - malloc 失败”中找到。
回答by MateuszL
Today I had the same issue. Git server ran out of memory, but gitlab reported that there is still memory available. We checked memory with htop (reported none available), restarted gitlab and everything went back to normal.
今天我遇到了同样的问题。Git服务器内存不足,但gitlab报告仍有可用内存。我们用 htop 检查了内存(报告没有可用),重新启动 gitlab,一切都恢复正常。
回答by Karthik Balu
sudo git pull
I faced the same error message every time I pull and sudo git pull
actually helped me to overcome this error message and pull was successful.
每次拉动时我都遇到相同的错误消息,sudo git pull
实际上帮助我克服了这个错误消息,拉动成功了。