繁体   English   中英

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

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

我在我的 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(-)

正如你在最后看到的 - 它很好地引入了我的本地更改。

但我只想摆脱这些错误,我该如何摆脱它们? 清除我的缓存?


我看到git gc是清理本地文件的推荐命令,但我什至无法运行它。

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

我也试过

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

最后,再运行一次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.

好吧,您的系统只是内存不足。 如果需要,Git 会定期运行git gc ,这就是错误消息的来源,您也可以在手动运行时看到。 它尝试重新打包您的 Git 存储库,但在尝试分配 293 MiB 额外 RAM 时失败。 将更多 RAM 放入您的盒子或至少扩大交换大小,即使只是暂时使重新打包成功完成。 如果您只想暂时添加一些交换文件以帮助重新打包完成,您可以在系统运行时轻松添加一些交换文件。 文档可以在https://help.ubuntu.com/community/SwapFaq#Four-step_Process_to_Add_Swap_File找到,如果只是临时的,则无需执行最后一步。

您的 RAM 大小可能会更低,您必须添加交换空间。 我已经在 ubuntu 16.04 中完成并解决了这个问题

下面的代码显示如果交换

free -h

如果交换为零,则检查是否有足够的内存来添加交换

df -h

我的 RAM 是 1 GB,因此也分配 1 GB 来交换空间

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

这将显示类似这样的内容,然后成功

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

谢谢

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

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

它应该减少所需的内存。

不过,至少有 1GB 的交换空间是个好主意。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM