简体   繁体   English

致命:内存不足,在 Ubuntu VM 上的 git pull 上 malloc 失败错误

[英]fatal: Out of memory, malloc failed error on git pull on Ubuntu VM

I ran git pull on my Ubuntu VM, and I got我在我的 Ubuntu VM 上运行了git pull ,我得到了

Enter passphrase for key '/root/.ssh/id_rsa': 
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 4), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
From bitbucket.org:bheng/app
   7406b4e..8f5e3dc  master     -> origin/master
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 5384, done.
fatal: Out of memory, malloc failed (tried to allocate 306851376 bytes)
error: failed to run repack
Updating 7406b4e..8f5e3dc
Fast-forward
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 5384, done.
fatal: Out of memory, malloc failed (tried to allocate 306851376 bytes)
error: failed to run repack
 resources/views/layouts/fe/meta.blade.php | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

As you can see at the end - it pull in my local changes fine.正如你在最后看到的 - 它很好地引入了我的本地更改。

But I just want to get rid of those errors, how do I get rid of them?但我只想摆脱这些错误,我该如何摆脱它们? Clear my cache?清除我的缓存?


I saw git gc is the recommended command to clean local files, but I can't even run that.我看到git gc是清理本地文件的推荐命令,但我什至无法运行它。

Counting objects: 7709, done.
fatal: Out of memory, malloc failed (tried to allocate 306851376 bytes)
error: failed to run repack

I also tried我也试过

git fsck git fsck

Checking object directories: 100% (256/256), done.
Checking objects: 100% (2377/2377), done.
dangling commit 32c8482dcc118bd64c1f8e45ee093c286a840e5d
dangling commit abce13f3bfb8c3833c7b76f4aea9cd28caa3af03
dangling blob c9131033c721c0b90c86bf7b32377588354363ec
dangling commit de6d83d883d35f97cb211233e2283c9d79e6f922
dangling blob d535c98d611cca74af45633c77680bb2bdc5e55a

Finally, run git pull one more time got this最后,再运行一次git pull得到这个

Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 5384, done.
fatal: Out of memory, malloc failed (tried to allocate 306851376 bytes)
error: failed to run repack
Already up-to-date.

Well, your system is simply out of RAM.好吧,您的系统只是内存不足。 Git regularly runs git gc if needed and that is where the error message comes from as you also can see when running it manually.如果需要,Git 会定期运行git gc ,这就是错误消息的来源,您也可以在手动运行时看到。 It tries to repack your Git repository and it fails when trying to allocate 293 MiB additional RAM.它尝试重新打包您的 Git 存储库,但在尝试分配 293 MiB 额外 RAM 时失败。 Put more RAM into your box or at least enlarge the swap size, even if only temporary to make the repack finish successfully.将更多 RAM 放入您的盒子或至少扩大交换大小,即使只是暂时使重新打包成功完成。 You can easily add some swap file while the system is running if you only want to make this temporarily to help the repack to finish.如果您只想暂时添加一些交换文件以帮助重新打包完成,您可以在系统运行时轻松添加一些交换文件。 Documentation can be found at https://help.ubuntu.com/community/SwapFaq#Four-step_Process_to_Add_Swap_File without doing the last step if only temporary.文档可以在https://help.ubuntu.com/community/SwapFaq#Four-step_Process_to_Add_Swap_File找到,如果只是临时的,则无需执行最后一步。

Your RAM size may will be lower, you have to Add Swap Space.您的 RAM 大小可能会更低,您必须添加交换空间。 I had done it in ubuntu 16.04 and solved this issue我已经在 ubuntu 16.04 中完成并解决了这个问题

The below code displays if swap下面的代码显示如果交换

free -h

if swap is zero then check there is enough memory to add the swap如果交换为零,则检查是否有足够的内存来添加交换

df -h

My RAM is 1 GB so allocating 1GB to swap space also我的 RAM 是 1 GB,因此也分配 1 GB 来交换空间

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show

This will display something like this, then success这将显示类似这样的内容,然后成功

NAME      TYPE  SIZE USED PRIO
/swapfile file 1024M   0B   -1

Thanks谢谢

Try following the instructions here: https://stackoverflow.com/a/8761464/1278288尝试按照此处的说明操作: https : //stackoverflow.com/a/8761464/1278288

git config --global pack.windowMemory "100m" git config --global pack.packSizeLimit "100m" git config --global pack.threads "1"

It should reduce the memory needed.它应该减少所需的内存。

It's a good idea to have at least 1gb of swap though.不过,至少有 1GB 的交换空间是个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git,致命:无法访问“https://github.com/path/to/repo.git”:gnutls_handshake() 失败:pull 函数出错 - Git, fatal: unable to access 'https://github.com/path/to/repo.git': gnutls_handshake() failed: Error in the pull function Golang:致命错误:运行时:内存不足 - Golang : fatal error: runtime: out of memory Ubuntu 12.04 LTS VirtualBox VM&Python 2.7.3-&#39;sudo pip install matplotlib&#39;致命错误 - Ubuntu 12.04 LTS VirtualBox VM & Python 2.7.3 - 'sudo pip install matplotlib' fatal error git pull &amp; git clone hang - Linux Ubuntu - git pull & git clone hang - Linux Ubuntu 我的网站一直用完 memory(致命错误) - My website keeps running out of memory (fatal error) Ubuntu Linux git gc说错误:无法运行重新包装 - Ubuntu Linux git gc says error: failed to run repack git pull / push返回:致命:协议错误:行长错误字符:_ - git pull / push returns: fatal: protocol error: bad line length character: _ Ubuntu,如何处理错误“<stdin> :1:10:致命错误:git2.h:没有这样的文件或目录”?</stdin> - Ubuntu, how to deal the error "<stdin>:1:10: fatal error: git2.h: No such file or directory"? 使用Ubuntu 16.04.2 LTS进行GIT Pull - GIT Pull using Ubuntu 16.04.2 LTS 致命错误:Ubuntu中的特征/特征值 - fatal error: Eigen/Eigenvalues in ubuntu
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM