hg8 hg8 - 11 months ago 82
Git Question

git Fatal: Out of memory, malloc failed on branch push

I know this has been asked a lot on StackOverflow but I did not manage to get any solution to solve my problem.

My coworker assigned me on a new project. The application is hosted on test Debian server with git installed.

First I have created my branch :

git checkout -b mybranch

Then I have done small modifications to some files.

When I tried to push it to Github (using my github account)

git add myfile.php
git commit -m "my first commit"
git push origin mybranch

I get this error :

fatal: Out of memory, malloc failed

I don't understand what this mean. The total size of the files I tried to push is 156Ko. Moreover the total size of the project is only 10,9Mo.

I tried to reboot the server but the same happen.

When I run
on the server I get :

total used free shared buffers cached
Mem: 505312 239532 265780 0 51576 71580
-/+ buffers/cache: 116376 388936
Swap: 0 0 0

My coworkers never had this problem before, even on the same test server.

Can someone highlight me on the reason of this error and a possible workaround?

Thanks in advance.

Answer Source

From the error message, it's not clear to me whether the error is on the local or the remote side.

Since it works for you coworker, the problem is probably on your computer. Maybe the Git repo is damaged. Try check it with git fsck

You can also clone the remote repo a second time as /tmp/test1 and then try git push /tmp/test1. If this works, the problem is remote. If it fails, there is something wrong on your PC.

On your PC, check that you have enough memory free and how much memory a single process can request. On Linux, use ulimit -a for this.

[EDIT] Also the output of free suggests that you only have 256MB of free memory (you can verify with free -h to more readable numbers). That's barely enough to run most programs today. Git needs a lot of memory to do its magic, so yes, you might actually have too little memory free.