Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push: fatal: Out of memory, malloc failed

Tags:

git

When pushing to a remote server I get the error:

Counting objects: 58, done.
Compressing objects: 100% (35/35), done.
fatal: Out of memory, malloc failed (tried to allocate 595059947 bytes)
error: pack-objects died of signal 13
error: failed to push some refs to '[email protected]:development'"

I think the problem is that I accidentally comitted some very big log files. But I subsequently removed them (git rm logfile), but the error remains. And they do not show up in "git status". How do I recover from this?

like image 983
Rune Avatar asked Jun 21 '12 09:06

Rune


3 Answers

I couldn't tell by your comment if you were objecting to rewriting history, or did not object. If you don't object, this command will erase the large files from your history.

Warning: this is destructive and irreversible. Backup your repository first. If you don't like the results, you can simply restore the backup:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch <file>' \
--prune-empty --tag-name-filter cat -- --all

That command will erase <file> from your branch's history. Run it for each file causing you trouble.

like image 64
Christopher Avatar answered Oct 22 '22 22:10

Christopher


The following command fixed the issue for me:

git config --global pack.windowMemory 256m

This affects effectiveness of delta compression so you might want to try a bigger size first, something like 1g, depending on your hardware and bandwidth.

More details here: https://www.kernel.org/pub/software/scm/git/docs/git-pack-objects.html

like image 3
keremispirli Avatar answered Oct 22 '22 23:10

keremispirli


I experienced this error while pushing to a git-repo hosted on a raspberry pi. One of the files I attempted to push are larger than the available memory (memory + swap) on the git server.

Solved the issue by temporary creating a new swapfile on the git server:

dd if=/dev/zero of=/media/store/swapfile bs=1024 count=655360

mkswap /media/store/swapfile

swapon /media/store/swapfile

Verify that a new swap partition was added by running:

swapon, cat /proc/swaps or free

(I choose not to add the swapfile to /etc/fstab, so the swapfile will be gone after a reboot.)

like image 1
andrel Avatar answered Oct 22 '22 23:10

andrel