簡體   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