git push 内存不足,malloc 失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8855317/
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-10 12:44:26  来源:igfitidea点击:

git push Out of memory, malloc failed

gitgithub

提问by Jared Knipp

I am trying to push my changes remotely to GitHub, every so often gitfails due to

我正在尝试将我的更改远程推送到 GitHub,由于git经常失败

C:\dev\projects>git push -v
Pushing to https://[email protected]/mycompany/My-Project.git
Password for 'github.com':
fatal: Out of memory, malloc failed (tried to allocate 524288000 bytes)
fatal: write error: Invalid argument

This is very, very aggravating. I have run the following commands, upgraded git(which wiped out my settings and caused lots of pain, but I digress)

这是非常非常严重的。我已经运行了以下命令,升级了git(它清除了我的设置并造成了很多痛苦,但我离题了)

git gc --auto --prune=today --aggressive
git repack

I have even bumped the value of

我什至提高了价值

http.postbuffer

but eventually it will fail again.

但最终它会再次失败。

This is a typical Rails 3.1 application, total project size on disk is 9.69 MB.

这是一个典型的 Rails 3.1 应用程序,磁盘上的项目总大小为 9.69 MB。

回答by Diego Pino

My advice is to try several git parameters related with pack:

我的建议是尝试几个与 pack 相关的 git 参数:

[pack]
   threads = 1
   deltaCacheSize = 128m
   windowMemory = 50m

What it got better results for me was setting git config pack.threads 1and git config pack.windowMemory 50m(default is 10m).

对我来说更好的结果是设置git config pack.threads 1git config pack.windowMemory 50m(默认为 10m)。

Still, my host didn't have enough RAM memory (2GB) and kept failing. I hard copied the repo and moved it to another machine with more RAM (8GB). It got better but still failed.

尽管如此,我的主机没有足够的 RAM 内存 (2GB) 并且一直失败。我硬复制了 repo 并将其移动到另一台具有更多 RAM (8GB) 的机器上。它变得更好,但仍然失败。

Finally, I downloaded the latest version of git (https://github.com/git/git), compile it and install it. That fixed the problem just by running git repack -adfwith the same parameters. After that I run git gc --aggressive --prune=now

最后,我下载了最新版本的git(https://github.com/git/git),编译安装。只需git repack -adf使用相同的参数运行即可解决问题。之后我跑git gc --aggressive --prune=now

Once I got the repo fixed in my local machine I pushed it to master, overwriting the remote repo, git push -f origin master.

一旦我定格在我的本地机器回购我把它推到大师,覆盖远程回购,git push -f origin master

To prevent similar errors in the future try not to add unnecessary large files to the repo (in my case I got a SQL dump of 3.5GB :)) and disable delta compression for large files (such as images, PDFs, videos). Add the following lines to .gitattributes:

为防止将来出现类似错误,尽量不要向存储库添加不必要的大文件(在我的情况下,我得到了 3.5GB 的 SQL 转储 :))并禁用大文件(例如图像、PDF、视频)的增量压缩。将以下行添加到.gitattributes

*.pdf -delta
*.jpg -delta

回答by ralphtheninja

You could try changing the config for repack with

您可以尝试更改重新打包的配置

git config --global pack.windowMemory 256m

回答by Knase

Use this:

用这个:

git gc --auto --prune=today --aggressive 
git repack 
git config --global http.postbuffer 524288000 
git config --global pack.windowMemory 256m

Its fixes for me.

它为我修复。

回答by Adrian Garcia

I had the same issue and after changing some parameters to 1024m the problem persisted:

我遇到了同样的问题,将一些参数更改为 1024m 后,问题仍然存在:

[pack]
     threads = 1
     deltaCacheSize = 1024m
     packSizeLimit = 1024m
     windowMemory = 1024m
[core]
     packedGitLimit = 1024m
     packedGitWindowSize = 1024m

I think the issue is related to the free RAM memory of your PC.

我认为这个问题与您 PC 的可用 RAM 内存有关。

Mine was quite busy, and after rebooting it I could finally push the changes.

我的很忙,重新启动后我终于可以推送更改了。

Hope it helps.

希望能帮助到你。

回答by sirs05

for someone who use gitlab and see this error

对于使用 gitlab 并看到此错误的人

find gitlab config (/etc/gitlab/gitlab.rb)

找到 gitlab 配置(/etc/gitlab/gitlab.rb)

change the value of gitlab_rails['git_max_size'](to a bigger value)

更改gitlab_rails['git_max_size']的值(更大的值)

then: gitlab-ctl reconfigureto refresh

然后:gitlab-ctl 重新配置刷新

回答by Raunak Agrawal

git repack 
git config --global http.postbuffer 524288000 
git config --global pack.windowMemory 256m

It fixed for me. and do git push after it.

它为我修好了。并在它之后执行 git push 。

回答by Rick

If you are on Gitlab find the repo that's causing the problem on the remote server.

如果您在 Gitlab 上,请找到导致远程服务器出现问题的存储库。

Gitlab stores the repositories in this location

Gitlab 将存储库存储在此位置

/var/opt/gitlab/git-data/repositories

Find the directory and run this command.

找到目录并运行此命令。

git repack -a -f -d

Done.

完毕。

回答by TimP

I had the same problem on an AWS t2.small. Also running sonar. I shutdown Sonar to free memory, checked out and restarted Sonar. I will increase the instance size.

我在 AWS t2.small 上遇到了同样的问题。还运行声纳。我关闭声纳以释放内存,检查并重新启动声纳。我将增加实例大小。

回答by tamasgal

In my case it had nothing to do with the client machine. This happened to me because the memory of the server where GitLab is running went full. I increased the memory of that virtual machine and the problem was solved.

在我的情况下,它与客户端机器无关。这发生在我身上,因为运行 GitLab 的服务器的内存已满。我增加了那个虚拟机的内存,问题就解决了。

回答by Mau

i deleted these settings in my .gitconfig file:

我在 .gitconfig 文件中删除了这些设置:

[http]
postbuffer = 524288000
[pack]
windowMemory = 1024m
deltaCacheSize = 1024m
packSizeLimit = 1024m

and the push worked again

然后推动又奏效了