3

When I do git push remotename branchname to my remote on my shared hosting with 1and1 I get the following error message:

Counting objects: 7, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 688 bytes | 0 bytes/s, done.
Total 7 (delta 2), reused 0 (delta 0)
remote: fatal: Out of memory, realloc failed

I have post-receive in hooks of my remote git repo set up with the following code:

#!/bin/sh
git --work-tree=/absolute/path/to/remotedir --git-dir=/absolute/path/to/remotedir/live.git checkout -f

When I SSH to my remote and issue free I see there's plenty of free memory (not sure if this has anything to do with my problem):

             total       used       free     shared    buffers     cached
Mem:      12330360   11796336     534024      32080      25248    8553496
-/+ buffers/cache:    3217592    9112768
Swap:       270332       3552     266780

My remote is using:

Debian 3.14.73-2~ui80+4
git version 2.1.4

My local is using:

OS X 10.11.2
git version 2.4.9 (Apple Git-60)

Really not sure why this is happening. Any help appreciated!

EDIT

When I run ulimit -a on the remote I get:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 1
file size               (blocks, -f) unlimited
pending signals                 (-i) 16382
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 512
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) 1800
max user processes              (-u) 42
virtual memory          (kbytes, -v) 786432
file locks                      (-x) unlimited
hot_barbara
  • 522
  • 1
  • 8
  • 19
  • From the error message, it points to git process on remote host seem to be hitting a memory limit. As the user the post-hook runs, check limits of that user "ulimit -a" (or) if the user has any restrictions on memory limits. Also I would check "dmesg" or /var/log/messages output – VenkatC Sep 18 '16 at 23:41
  • @VenkatC please see the edit in my post. Is the memory limit(s) sufficient? Thank you! – hot_barbara Sep 19 '16 at 00:00
  • Also there's nothing coming from dmesg and there's no /var/log/messages file. – hot_barbara Sep 19 '16 at 00:06
  • virtual memory (kbytes, -v) 786432 ==> Looks like there is a limit set on user virtual memory to be 768MB. Check /etc/security/limits.conf and if any limits set there - you would want to bump them up, based on how much memory may be required for your git project/post-hook scripts to work – VenkatC Sep 19 '16 at 00:08
  • if "ulimit -v H" shows unlimited, then there may be some limit in your shell profiles/logon scripts. You can set limit to be unlimited temporarily using 'ulimit -Sv unlimited' – VenkatC Sep 19 '16 at 00:10
  • All the lines in limits.conf are commented out and I can't write them because I don't have permissions to do so (I'm on a shared hosting package with 1and1). `ulimit -Hv` shows 786432 and when I issue `ulimit -Sv unlimited` nothing seems to change. – hot_barbara Sep 19 '16 at 00:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/123659/discussion-between-venkatc-and-user2731260). – VenkatC Sep 19 '16 at 00:36

5 Answers5

3

Thanks to @Елин Й. for sharing ! But with the syntax we have had some problems, but maybe works for his server. For 1and1 we had to use this git config to make the remote repo work:

[core]
    packedGitWindowSize = 640m
    packedGitLimit = 640m
    preloadindex = false

[pack]
    windowMemory = 640m
    threads = 1
Simon Franzen
  • 2,628
  • 25
  • 34
2

I have somehow managed to fix this issue. At least, I haven't got it for a few months. Since I did many trials and errors, reading many different suggestions etc., I don't know exactly what configuration change fixed it.

Hence, I want to share my git config to help others as a reference:

core.preloadindex=false
core.packedgitwindowsize=640m
core.packedgitlimit=640m
pack.windowmemory=640m
pack.threads=1
Елин Й.
  • 953
  • 10
  • 25
1

As per the ulimit, your hosting server had set per-process limit on virtual memory to be 768MB. Your post-hook script is getting killed, as its requirements are probably crossing the limits.

You could try to update your git config to suit your environment. There are some pointers here at

https://github.com/hbons/SparkleShare/issues/519#issuecomment-3471638

Lucas
  • 523
  • 2
  • 10
  • 20
VenkatC
  • 602
  • 3
  • 5
1

On the 1and1 host, at the command prompt...

ulimit -a

reported several things ... one was:

open files (-n) 512

ran command:

ulimit -Sn unlimited

and it changed to:

open files (-n) 1024

Then the git commit would work. No more error.

PCoughlin
  • 153
  • 10
0

I was having this error on checking out a branch. I had to delete the ".git/hooks/post-checkout" file and it worked for me. Just mentioned if anyone else encounter with same kind of issue.

M Umar
  • 11
  • 2