6

Tried below command and facing error.

> git gc
Counting objects: 6342699, done.
warning: suboptimal pack - out of memory
fatal: Out of memory, malloc failed (tried to allocate 239971384 bytes)
error: failed to run repack

I have tried

  1. git config --global pack.windowMemory 256m

  2. git repack -a -f -d

  3. update the latest git extension

  4. git gc --aggressive --prune=now

I have tried so many options. But still my facing this issue. Any idea why I'm getting this error?

Holger Just
  • 52,918
  • 14
  • 115
  • 123
Selva
  • 179
  • 1
  • 3
  • 13
  • 1
    At a guess: someone committed a massive file to git? Don't commit 200 gigabyte files to source control, that's what artifact repositories are for. You should copy the files out of git and start a new repository without the massive binary files. Abandon the old repository. – Paul Hicks Feb 25 '14 at 08:53
  • Thanks for ur reply @PaulHicks. Can you please tell me. How to do this? – Selva Feb 26 '14 at 06:27
  • Depends on how big it is. Roughly speaking, make a copy of the repo, delete the .git directory, look for binary files that should be deleted and delete them, then run `git init` again, thereby creating a new repo. There are many variations on this theme, one of the alternatives may work for you. – Paul Hicks Feb 26 '14 at 07:16
  • Let me know if this works, I'll create an answer if it does, or if it helps you figure out what's wrong. – Paul Hicks Feb 26 '14 at 07:16
  • possible duplicate of [Repack of Git repository fails](http://stackoverflow.com/questions/4826639/repack-of-git-repository-fails) – Joe Sep 30 '14 at 14:49
  • FWIW, your #4 worked for me when nothing else would. After I ran `git gc --aggressive --prune=now`, I was able to run `git gc` without errors. – Ken Smith Oct 11 '18 at 17:09

1 Answers1

0

You can start setting the pack.deltaCacheSize to a lower value**. This parameter controls the maximum memory used for caching deltas during pack creation. Lowering it might reduce the memory usage, but it could also slow down the operation.

You can set it with the following command:

git config --global pack.deltaCacheSize 64m

More recently (Git 2.29+, Q4 2020), git maintenance can also be a viable alternative to git gc.

git maintenance run --task=gc
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250