Git错误:内存不足,malloc失败(尝试分配X字节)

6

最近我尝试克隆一个git仓库时,遇到了以下错误日志:

remote: Counting objects: 4607, done.
error: git upload-pack: git-pack-objects died with error.B/s      
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: fatal: Out of memory, malloc failed (tried to allocate 119483755 bytes)
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed

经过调查,看起来错误是来自仓库服务器。我通过ssh连接并尝试了以下所有方法(基本上是前两页谷歌搜索结果提出的所有解决方案):

  • Modified config file by adding the following lines:

    [core]
        packedGitLimit = 512m
        packedGitWindowSize = 512m
    [pack]
        windowMemory = 512m
        packSizeLimit = 512m
        deltaCacheSize = 512m
        threads = 1
        window = 0
    
  • Tried the following commands which yielded the following error logs:

    1. git repack -a -f -d

      Counting objects: 4607, done.
      fatal: Out of memory, malloc failed (tried to allocate 119483755 bytes)
      
    2. git fsck

      fatal: Out of memory, malloc failed (tried to allocate 119483755 bytes)
      
    3. git gc

      fatal: Out of memory, malloc failed (tried to allocate 119483755 bytes)
      error: failed to run repack
      
  • So basically, it tells me that it is a memory error but I have enough memory :

    1. free -m

                   total       used       free     shared    buffers     cached
      Mem:         12043      10825       1217          0        192       8406
      -/+ buffers/cache:       2226       9816
      Swap:          258         30        228
      
    2. ulimit -a

      core file size          (blocks, -c) 0
      data seg size           (kbytes, -d) 131072
      scheduling priority             (-e) 0
      file size               (blocks, -f) unlimited
      pending signals                 (-i) 48169
      max locked memory       (kbytes, -l) 64
      max memory size         (kbytes, -m) unlimited
      open files                      (-n) 1024
      pipe size            (512 bytes, -p) 8
      POSIX message queues     (bytes, -q) 819200
      real-time priority              (-r) 0
      stack size              (kbytes, -s) unlimited
      cpu time               (seconds, -t) 1800
      max user processes              (-u) 90
      virtual memory          (kbytes, -v) 131072
      file locks                      (-x) unlimited
      

我需要帮助,谢谢。


1
可能存在其他内存限制,例如由cgroups使用强制实施的限制,cat /sys/fs/cgroup/memory/memory.limit_in_bytes在这种情况下可能会显示一些内容。 - J.J. Hakala
@J.J.Hakala 我的服务器是共享主机,所以我没有管理员权限,无法访问每个文件,但似乎你提到的文件在服务器上不存在。 - PJoy
可能是Git on Windows, "Out of memory - malloc failed"的重复问题。 - Vamsi Ravi
1个回答

8

以下更改应该放在哪个文件中? - Pipo
.gitconfig文件 - Umesh Patil

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接