git推出内存不足,malloc失败 [英] git push Out of memory, malloc failed

查看:713
本文介绍了git推出内存不足,malloc失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的更改远程推送到GitHub,每次 git 由于
$ b

  C:\dev\projects> git push -v 
推送到https://user@github.com/mycompany/My-Project.git
密码对于'github.com':
fatal:内存不足,malloc失败(试图分配524288000字节)
致命错误:写入错误:无效参数

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

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

我甚至碰到了

  http.postbuffer 

但最终会再次失败。



这是一个典型的Rails 3.1应用程序,磁盘上的项目总大小为9.69 MB。 我的建议是尝试几个与包相关的git参数:

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

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



没有足够的RAM内存(2GB)并保持faili NG。我硬拷贝回购,并将其移动到另一台具有更多内存(8GB)的机器上。它变得更好,但仍然失败。



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



本地机器我把它推到主,覆盖远程仓库, git push -f origin master 。为避免将来发生类似的错误,请不要将不必要的大文件添加到回购站(在我的情况下,我获得了3.5GB的SQL转储:))并禁用增量压缩大文件(如图像,PDF,视频)。将以下几行添加到 .gitattributes

  *。pdf -delta 
* .jpg -delta


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

C:\dev\projects>git push -v
Pushing to https://user@github.com/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 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.

解决方案

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

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

What it got better results for me was setting git config pack.threads 1 and git config pack.windowMemory 50m (default is 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.

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 -adf with the same parameters. After that I run 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.

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:

*.pdf -delta
*.jpg -delta

这篇关于git推出内存不足,malloc失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆