致命:在记忆中,malloc在ubuntu vm上的git rifer失败失败



我在我的ubuntu vm上ran 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.

好吧,您的系统简直就是不在RAM中。如果需要,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,因此分配1GB来交换空间

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交换是一个好主意。

最新更新