GIT:致命:内存不足,malloc 失败(尝试分配 889192448 字节)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41120920/
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: fatal: Out of memory, malloc failed (tried to allocate 889192448 bytes)
提问by Joe Sleiman
I have this error while pushing my project to tfs GIT.
将我的项目推送到 tfs GIT 时出现此错误。
fatal: Out of memory, malloc failed (tried to allocate 889192448 bytes)
致命:内存不足,malloc 失败(尝试分配 889192448 字节)
回答by David Pascoe-Deslauriers
I fixed this by decreasing the postbuffer
size:
我通过减小postbuffer
尺寸来解决这个问题:
[http]
postbuffer = 5m
回答by lin
Edit .git/config
on Unix or .gitconfig
on Windows and modifiy the following params. By running git config --list --show-origin
you could locate your gitconfigs.
.git/config
在 Unix 或.gitconfig
Windows上编辑并修改以下参数。通过运行git config --list --show-origin
你可以找到你的 gitconfigs。
[core]
packedGitLimit = 128m
packedGitWindowSize = 128m
[pack]
deltaCacheSize = 128m
packSizeLimit = 128m
windowMemory = 128m
[http]
postbuffer = 5m
If you are using git via CLI ensure you restart your shell/terminal after you changed this settings.
如果您通过 CLI 使用 git,请确保在更改此设置后重新启动 shell/终端。
回答by Pab
I solved this by adding memory to my server which was 512MB so I extend it to 2GB
我通过向我的服务器添加内存来解决这个问题,它是 512MB,所以我将它扩展到 2GB
回答by desflan
I fixed this by closing applications that use a lot of memory (visual studio, sql server), and pushing again
我通过关闭使用大量内存的应用程序(visual studio、sql server)并再次推送来解决这个问题
回答by Paulina
I had the same problem on windows, exept with checkout another branch. Finally, I couldn't either pull or fetch my project beacause I got out of memory error ("try to allocate..." etc). I did the trick with increasing git pack and core limits but it didn't work for me. Finally, I deleted git from computer and install again. Problem was solved.
我在 Windows 上遇到了同样的问题,除了结帐另一个分支。最后,我无法拉取或获取我的项目,因为我遇到了内存不足错误(“尝试分配...”等)。我通过增加 git pack 和核心限制来解决这个问题,但它对我不起作用。最后,我从计算机中删除了 git 并重新安装。问题解决了。
回答by Spencer Hill
In my experience this can happen for a few reasons:
根据我的经验,这可能有以下几个原因:
- Most commonly, there are one or more files that are too large for Git to handle. In my experience this is usually a .sql, .zip, .gz or media file. Simply removing them from the repository, however, won't resolve the issue because it's in the actual Git history (inside the .git folder both on your local machine and / or on your remote server that you're pulling from). I have yet to discover a way to completely remove it from all Git history, so I usually create a new repo, create a
.gitignore
file in that new repo and then copy my files over there. Not a good solution but it was my best solution until I can identify a way to completely remove it from all history. - It can also occur when the servers RAM / memory is low. (If you don't know how to increase your RAM then you probably shouldn't be using Git and should hire a professional developer to assist you.)
- 最常见的是,有一个或多个文件太大,Git 无法处理。根据我的经验,这通常是 .sql、.zip、.gz 或媒体文件。然而,简单地从存储库中删除它们并不能解决问题,因为它存在于实际的 Git 历史记录中(位于本地计算机和/或您从中提取的远程服务器上的 .git 文件夹中)。我还没有找到从所有 Git 历史记录中完全删除它的方法,所以我通常创建一个新的 repo,
.gitignore
在那个新的 repo 中创建一个文件,然后将我的文件复制到那里。不是一个好的解决方案,但它是我最好的解决方案,直到我能找到一种方法将它从所有历史记录中完全删除。 - 当服务器 RAM/内存不足时也会发生这种情况。(如果您不知道如何增加 RAM,那么您可能不应该使用 Git,而应该聘请专业的开发人员来帮助您。)
I'm not saying these are the only possibilities. But in my experience with at least a few hundred repositories it was one of these two things every time. Usually #1.
我并不是说这些是唯一的可能性。但根据我至少有几百个存储库的经验,每次都是这两件事之一。通常#1。
To see which files are the largest in your repository execute this command: ls -lS
要查看存储库中哪些文件最大,请执行以下命令: ls -lS
回答by user3785966
So what it basically requires is the free memory of 889192448 bytes (889MB Approx). This error occurs for 2 reasons
所以它基本上需要的是889192448字节(大约889MB)的空闲内存。发生此错误的原因有 2 个
- When your RAM is running out of space.
- Memory limit set for Git is not meeting the requirement.
- 当您的 RAM 空间不足时。
- 为 Git 设置的内存限制不符合要求。
To check the free memory on Linux based systems.
检查基于 Linux 的系统上的可用内存。
free -h
If free memory is greater than the required memory, then you don't have to do anything here, otherwise you need to add the swap memory to increase the available free space on RAM.
如果空闲内存大于需要的内存,那么这里你什么都不用做,否则你需要添加交换内存来增加 RAM 上的可用空闲空间。
If the free memory of RAM is already in place for the required memory, then you need to configure your git to utilise this. You do this with the following:
如果 RAM 的空闲内存已经为所需的内存准备好了,那么你需要配置你的 git 来使用它。您可以使用以下方法执行此操作:
git config pack.packSizeLimit 1g
git config pack.deltaCacheSize 1g
git config pack.windowMemory 1g
git config core.packedGitLimit 1g
git config core.packedGitWindowSize 1g
Hope this helps.
希望这可以帮助。
回答by István D?brentei
I had the same issue using Ubuntu with 1G RAM and I added some swap space (1G more). It is working.
我在使用带有 1G RAM 的 Ubuntu 时遇到了同样的问题,我添加了一些交换空间(多 1G)。这是工作。
回答by Umesh Patil
After long hours of search and not getting the solution, in frustration I had allocated "999999999" to postbuffer and it worked wonders. ;)
经过长时间的搜索并没有得到解决方案,我沮丧地将“999999999”分配给了后缓冲,它产生了奇迹。;)
[http]
postbuffer = 9999999999
Try this it may work for you also. Good Luck. :)
试试这个它也可能对你有用。祝你好运。:)