5

I'm using gitosis on a server that has a low amount of memory, specifically around 512 MB. When I try to push a large folder (happens to be a backup from an android phone), I get:

me@corellia:~/Configs/$ git push origin master

Counting objects: 18, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14/14), done.
fatal: Out of memory, malloc failed MiB | 685 KiB/s   
error: pack-objects died of signal 13
error: failed to push some refs to 'git@dagobah:Configs'

I've been searching the web, and notably found: http://www.mail-archive.com/git-users@googlegroups.com/msg01747.html as well as http://git.661346.n2.nabble.com/Out-of-memory-error-during-git-push-td5443705.html but these don't seem to help me for two reasons: 1) I am not actually out of memory when I push. When I run 'top' during the push, I get:

24262 git       18   0 16204 6084 1096 S    2  1.2   0:00.12 git-unpack-obje   

Also, during the push if I run /head/meminfo, I get:

MemTotal:       524288 kB
MemFree:        289408 kB
Buffers:             0 kB
Cached:              0 kB
SwapCached:          0 kB
Active:              0 kB
Inactive:            0 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       524288 kB

So, it seems that I have enough memory free, but it's actually still failing, and I'm not enough of a git guru to figure out what is happening. I would appreciate it if someone could give me a hand here and tell me what could be causing this problem, and what I can do to solve it.

Thanks!

EDIT:

The output of running the ulimit -a command:

scottj@dagobah:~$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 204800
max locked memory       (kbytes, -l) 32
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) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 204800
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

EDIT:

The git objects and sizes are:

313796  .git/objects/88/7ce48679f885af4c466d4ddccef9a9954a9de6
224276  .git/objects/18/261f6a52926a756c7ecb453e025d1f25937026
6248    .git/objects/63/a0b4e622c893d3dcc162052b43301030d0c86d
5608    .git/objects/a2/0c65987656cba591171549752eb97f0207fec8
2608    .git/objects/pack/pack-3be8300f69b67fa8fa687df84bbd9b8c96e86c8e.pack
28  .git/objects/pack/pack-3be8300f69b67fa8fa687df84bbd9b8c96e86c8e.idx
24  .git/objects/c9/8909563ec60369d69ac2d317af25a44c9fc198
24  .git/objects/5d/1f74bd9bc4c575a7eeec08d59916d9829068d1
24  .git/objects/53/edad79cb051f5e7864d9d3339fa59990ccfe2d
8   .git/objects/80/dd50c7a314950e5a1f56c0210b0a91f48ee792
jwir3
  • 155

2 Answers2

2

It is a bit of a stretch but give this a try

git -c core.packedGitWindowSize=32m -c core.packedGitLimit=256m push origin master

This overrides a couple of parameters that limit the number of bytes mapped from files. These are the defaults used for a 32-bit system, the 64-bit defaults are much larger. I'm speculating you are using a 64-bit system, which is causing git to use very large defaults, but there are resource constraints (perhaps from running in a VM) that trigger the error.

These configuration parameters and values came from http://schacon.github.com/git/git-config.html

0

What platform/distribution are you on? Ubuntu, redhat, centos, etc... Both for the client and server? What's the memory usage on the client you're pushing from? I've had this happen before with pushes which encompass a large # of revisions. I know one workaround is to incrementally push your changes to the server if at all possible. The other solution is to increase your kernel memory usage. With some kernel distributions, there are setting which prevent the kernel from allocation max memory to a single process:

Set Kernel Parameters
Modify the "/etc/sysctl.conf" file to include the lines appropriate to your operating system.
# Red Hat Enterprise Linux 3.0 and CentOS 3.x 
 kernel.shmmax = 2147483648
 kernel.shmmni = 4096
 kernel.shmall = 2097152
 kernel.shmmin = 1
 kernel.shmseg = 10

# semaphores: 
 semmsl, semmns, semopm, semmni kernel.sem = 250 32000 100 128
 fs.file-max = 65536

# Red Hat Enterprise Linux 4.0 and CentOS 4.x 
 kernel.shmmax = 536870912
 kernel.shmmni = 4096
 kernel.shmall = 2097152

If your git process exceeds the limits, the kernel will kill the process despite the max memory reported being available on your system.

Note: be careful with these settings. You probably don't want to use the settings in that example as i pulled them from a server in our environment.

A few extra notes to mention:

To Update and test kernel settings with sysctl, use following commands:

List current settings: sysctl -A|grep shm

sysctl -w kernel.shmmax=<value> to write in sysctl.conf
sysctl -p /etc/sysctl.conf to read/reload the values from sysctl.conf

Disable secure linux by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.

SELINUX=disabled