我怎样才能从“致命的:内存不足? mmap失败:无法分配内存“在Git中? [英] How can I recover from "fatal: Out of memory? mmap failed: Cannot allocate memory" in Git?
问题描述
让我从一些背景入手:
我必须将一个关键的Magento网店升级到新版本。为了确保所有现有的代码在升级后仍然有效并进行一些升级后的更改,我从整个Magento安装(不包括4.5GB图像,./var目录等明显内容)中创建了一个Git存储库,并将其克隆到开发服务器上。创建了一个新的分支,执行了升级,完成了代码更改,将其全部提交给开发分支,并将其推回原点。
现在升级'real'商店,这意味着我必须将生产服务器上的master分支与dev分支合并。然后,everyhing会出错:
git fetch
- 作品
* master
git merge origin / dev
会出现可怕的错误(仅在等待之后输出):
致命:内存不足? mmap失败:无法分配内存
同样适用于 git checkout dev
, git rebase master master origin / dev
等等。
在现有问题的stackoverflow上做了一些研究,并花了一个晚上尝试建议,包括(但不限于):
git gc
计数对象:48154,done。
使用多达2个线程的增量压缩。
压缩对象:100%(37152/37152),完成。
fatal:内存不足,malloc失败(试图分配527338875字节)
错误:无法运行重新打包
和
git repack -a -d --window-memory 10m --max-包装尺寸20m
计数对象:48154,完成。
使用多达2个线程的增量压缩。
压缩对象:100%(37152/37152),完成。
fatal:内存不足,malloc失败(试图分配527338875字节)
另外到以前的命令,我也试过
由于 link 提到了32位系统的一个可能的问题,或许提及三个系统的规格是明智的:
- 'dev'server:x86_64 Gentoo 2.6.38-hardened-r6 // 4个内核& 8GB内存
- 'origin'服务器:x86_64 Gentoo 2.6.38-hardened-r6 // 2个内核& 4GB内存
'live'服务器:x86_64 Debian 4.3.2-1.1 2.6.35.5-pv1amd64 //(VPS)2个内核& 3GB内存
有谁知道我可以如何从此恢复?重新包装原产地工作?如果是这样,我该如何说服生产服务器获取存储库的新副本?
任何帮助都将不胜感激!
您收到的错误来自存储库中的大文件。
尝试升级Git
<上个月发布了Git 1.7.6,并在其发行说明中提供了这一点:
添加一个大于core.bigfilethreshold的文件(默认为1/2 Gig)将使用git add将内容直接发送到packfile,而不必在存储器中同时保存它和它的压缩表示。
升级到1.7.6可能会让您运行 git gc
,甚至可能
尝试删除有效文件
如果升级Git没有帮助,可以尝试使用 git filter-branch
从存储库中删除大文件。 。在这之前,请尝试使用 git cat-file -p< commit_sha1>:path / to / large / file> / path / to / backup / of / large / file来备份大文件
。
您需要在最强壮的机器上执行这些操作(大量内存)。
如果这可行,请尝试重新克隆到其他机器(或简单地rsync .git
目录)。
Let me start with some context:
I had to upgrade a crucial Magento webshop to a new version. To be sure all existing code would still work after the upgrade and make some post-upgrade changes I made a Git repository from the entire Magento installation (excluding obvious content like the 4.5GB of images, ./var directory etc.), pushed it to an origin and cloned it on a dev server. Made a new branch, performed the upgrades, made code changes, committed it all to the dev branch and pushed it back to origin.
Now the time has come to upgrade the 'real' shop, meaning i have to merge the master branch on the production server with the dev branch. And then everyhing goes wrong:
git fetch
- works
git branch
says: * master
git merge origin/dev
goes horribly wrong (only output after some waiting):
fatal: Out of memory? mmap failed: Cannot allocate memory
Same goes for git checkout dev
, git rebase master origin/dev
etc.
Did some research here on stackoverflow in existing questions and spent an evening of trying suggestions, including (but not limited to):
git gc
Counting objects: 48154, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (37152/37152), done.
fatal: Out of memory, malloc failed (tried to allocate 527338875 bytes)
error: failed to run repack
and:
git repack -a -d --window-memory 10m --max-pack-size 20m
Counting objects: 48154, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (37152/37152), done.
fatal: Out of memory, malloc failed (tried to allocate 527338875 bytes)
In addition to the previous command, i also tried this (which is pretty similar). As the link makes mention of a possible issue with 32-bit systems, perhaps it's wise to mention the specs for the three systems involved:
- 'dev' server: x86_64 Gentoo 2.6.38-hardened-r6 // 4 cores & 8GB RAM
- 'origin' server: x86_64 Gentoo 2.6.38-hardened-r6 // 2 cores & 4GB RAM
- 'live' server: x86_64 Debian 4.3.2-1.1 2.6.35.5-pv1amd64 // (VPS) 2 cores & 3GB RAM
Does anyone know how I can recover from this? Does repacking on origin work? If it does, how can I convince the production server to fetch a new copy of the repository? Any help would be greatly appreciated!
The error you're getting comes from the large files in your repository. Git is trying to put the entire contents of the file in memory, which makes it croak.
Try Upgrading Git
Git 1.7.6 was released last month and has this lovely bit in its release notes:
Adding a file larger than core.bigfilethreshold (defaults to 1/2 Gig) using "git add" will send the contents straight to a packfile without having to hold it and its compressed representation both at the same time in memory.
Upgrading to 1.7.6 might enable you to run git gc
and maybe even git merge
, but I can't verify because it's hard get a repository into that state (the conditions must be just right).
Try Removing the Offending Files
If upgrading Git doesn't help, you can try removing the large files from the repository using git filter-branch
. Before you do that, try backing up the large files using git cat-file -p <commit_sha1>:path/to/large/file >/path/to/backup/of/large/file
.
You'll want to do these operations on your most beefy machine (lots of memory).
If this works, try re-cloning to the other machines (or simply rsync the .git
directory).
这篇关于我怎样才能从“致命的:内存不足? mmap失败:无法分配内存“在Git中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!