26

I have this error while pushing my project to tfs GIT.

fatal: Out of memory, malloc failed (tried to allocate 889192448 bytes)

lin
  • 17,956
  • 4
  • 59
  • 83
Joe Sleiman
  • 2,416
  • 5
  • 25
  • 40

9 Answers9

23

I fixed this by decreasing the postbuffer size:

[http]
    postbuffer = 5m
Dherik
  • 17,757
  • 11
  • 115
  • 164
19

Edit .git/config on Unix or .gitconfig on Windows and modifiy the following params. By running git config --list --show-origin you could locate your gitconfigs.

[core]
  packedGitLimit = 128m
  packedGitWindowSize = 128m

[pack]
  deltaCacheSize = 128m
  packSizeLimit = 128m
  windowMemory = 128m

[http]
  postbuffer = 5m

If you are using git via CLI ensure you restart your shell/terminal after you changed this settings.

lin
  • 17,956
  • 4
  • 59
  • 83
5

So what it basically requires is the free memory of 889192448 bytes (889MB Approx). This error occurs for 2 reasons

  • When your RAM is running out of space.
  • Memory limit set for Git is not meeting the requirement.

To check the free memory on Linux based systems.

free -h

If free memory is greater than the required memory, then you don't have to do anything here, otherwise you need to add the swap memory to increase the available free space on RAM.

If the free memory of RAM is already in place for the required memory, then you need to configure your git to utilise this. You do this with the following:

git config pack.packSizeLimit 1g
git config pack.deltaCacheSize 1g
git config pack.windowMemory 1g
git config core.packedGitLimit 1g
git config core.packedGitWindowSize 1g

Hope this helps.

user3785966
  • 2,578
  • 26
  • 18
3

I fixed this by closing applications that use a lot of memory (visual studio, sql server), and pushing again

desflan
  • 468
  • 3
  • 13
2

I solved this by adding memory to my server which was 512MB so I extend it to 2GB

Pab
  • 21
  • 4
  • 1
    I had a situation where the git server (Gitlab) was trying to send me the repo. This failed because the server ran out of memory. I restarted and added more memory, which solved the issue. Mentioning it here in case someone is searching for Gitlab specifically, as I was. – CoderGuy123 Jul 09 '18 at 20:48
1

I had the same problem on windows, exept with checkout another branch. Finally, I couldn't either pull or fetch my project beacause I got out of memory error ("try to allocate..." etc). I did the trick with increasing git pack and core limits but it didn't work for me. Finally, I deleted git from computer and install again. Problem was solved.

Paulina
  • 930
  • 8
  • 13
1

In my experience this can happen for a few reasons:

  1. Most commonly, there are one or more files that are too large for Git to handle. In my experience this is usually a .sql, .zip, .gz or media file. Simply removing them from the repository, however, won't resolve the issue because it's in the actual Git history (inside the .git folder both on your local machine and / or on your remote server that you're pulling from). I have yet to discover a way to completely remove it from all Git history, so I usually create a new repo, create a .gitignore file in that new repo and then copy my files over there. Not a good solution but it was my best solution until I can identify a way to completely remove it from all history.
  2. It can also occur when the servers RAM / memory is low. (If you don't know how to increase your RAM then you probably shouldn't be using Git and should hire a professional developer to assist you.)

I'm not saying these are the only possibilities. But in my experience with at least a few hundred repositories it was one of these two things every time. Usually #1.

To see which files are the largest in your repository execute this command: ls -lS

Spencer Hill
  • 1,043
  • 2
  • 15
  • 38
0

I had the same issue using Ubuntu with 1G RAM and I added some swap space (1G more). It is working.

István Döbrentei
  • 948
  • 10
  • 20
-1

After long hours of search and not getting the solution, in frustration I had allocated "999999999" to postbuffer and it worked wonders. ;)

[http]
    postbuffer = 9999999999

Try this it may work for you also. Good Luck. :)

Umesh Patil
  • 4,668
  • 32
  • 24