4

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 free 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.

hg8
  • 1,082
  • 2
  • 15
  • 28

3 Answers3

1

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.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • Indeed on my local PC it works fine so the problem is not on remote. I now need to find how to solve this on the test server. Thanks for your answer! – hg8 May 13 '15 at 14:14
  • That comment doesn't make sense. You said it doesn't work locally and now you say it works fine. My guess is that you have a local problem, especially since your coworker can push. You should also check how big your local repository is. Maybe you accidentally committed a huge file. Even if you delete that again, Git will remeber that it once was there and its full content. – Aaron Digulla May 13 '15 at 14:17
  • No, maybe I have not explained the problem properly. We work directly on the test server. When everything is ok we push our changes to github *from* the test server. My coworker were able to push from the test server before me. What I did following your answer was to clone the repo on my PC, make the same changes on the files and then push it to github. That confirm the problem come from the test server and not the github repo/branch... – hg8 May 13 '15 at 14:28
  • Specifically, it comes from you user account on the test server. See my edits. – Aaron Digulla May 13 '15 at 15:17
  • Indeed it was a ram problem. I never tough that 200 free mo were not enough for git to function properly. Thanks for your help. – hg8 May 15 '15 at 07:00
0

One other possibility for this problem, especially if you're provisioning a new server is to make sure you have a swapfile. This was my case with a new CentOS 6.7. You can try:

swapon -s

If there is no file then, if you're like me, that could be the solution (creating one). For CentOs you can follow https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-swap-adding.html. And just google if you have another distro.

Alexi
  • 1
0

The reason for this COULD be a few large files in the repository.. Perhaps Zip Files, particularly if you have a plugin which backs up your code / database.

To check for these large files, cd into the root folder of your repository and run:

find . -size +10M -ls

This will surface the larger files.

At that point you may:

  1. ignore these files by creating .gitignore and adding the path those files are located

or if it important

  1. Create a .gitattributes file in the root directory with this code (if the large files are all zip files): *.zip binary -delta

This will make sure you're treating zip files as binary files - not tracking the changes made in them.

If that doesn't work, you may want to visit this answer here and try them out:

Git on Windows, "Out of memory - malloc failed"

Good luck!

Community
  • 1
  • 1
Seth
  • 134
  • 1
  • 14