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

9,797

Turn out it was indeed a ram problem. 268mo was not enough for git to function properly.

I solved the problem by adding 1Go of swap to the server:

$ sudo fallocate -l 1G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
Share:
9,797

Related videos on Youtube

hg8
Author by

hg8

Updated on September 18, 2022

Comments

  • hg8
    hg8 over 1 year

    I know this has been asked a lot 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.

    • 111---
      111--- almost 9 years
      Have you tried changing the settings in .git/config as suggested here?
    • hg8
      hg8 almost 9 years
      Yes but no luck...
    • 111---
      111--- almost 9 years
      Can you try again with the -v flag, git push -v, and post the full error (redacting your repo info of course).
    • hg8
      hg8 almost 9 years
      The -v flag does not add anything to the error message...
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' almost 9 years
      This looks like a bug somewhere. What version of Debian does the machine have? Can you reproduce the problem by cloning a local repository rather than one on github? If you can reproduce the problem without using any credentials or private information, run strace -o git.strace -tt git push origin mybranch (or whatever the failing git … command is) and post the resulting git.strace file (don't post the trace if it might contain something like a password).
  • Pramod
    Pramod almost 8 years
    How did you do that, Im getting same issue.
  • Anonymous
    Anonymous almost 4 years
    This turned out to be my issue as well. Running on a small AWS EC2