Youcompleteme: Compilation runs out of memory

0

I have a 1GB VM (A t2.micro AWS EC2 instance) that I'm trying to set YCM up on, and I can't do it because it fails.

[ 97%] Building CXX object ycm/CMakeFiles/ycm_core.dir/PythonSupport.cpp.o
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Result.cpp.o
[ 98%] Building CXX object ycm/CMakeFiles/ycm_core.dir/Utils.cpp.o
[100%] Building CXX object ycm/CMakeFiles/ycm_core.dir/versioning.cpp.o
[100%] Building CXX object ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o
Traceback (most recent call last):
  File "/home/centos/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 176, in <module>
    Main()
  File "/home/centos/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 171, in Main
    BuildYcmdLibs( GetCmakeArgs( args ) )
  File "/home/centos/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 149, in BuildYcmdLibs
    sh.make( '-j', NumCores(), build_target, _out = sys.stdout )
  File "/home/centos/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 1021, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/home/centos/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 486, in __init__
    self.wait()
  File "/home/centos/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 500, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/centos/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 516, in handle_command_exit_code
    raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_2:

  RAN: '/usr/bin/make -j 1 ycm_support_libs'

  STDOUT:


  STDERR:
virtual memory exhausted: Cannot allocate memory
make[3]: *** [ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o] Error 1
make[2]: *** [ycm/CMakeFiles/ycm_core.dir/all] Error 2
make[1]: *** [ycm/CMakeFiles/ycm_support_libs.dir/rule] Error 2
make: *** [ycm_support_libs] Error 2

Here's top:

top - 10:38:57 up 19 min,  1 user,  load average: 0.00, 0.19, 0.31
Tasks: 109 total,   3 running, 106 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.7 us,  0.3 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   1016652 total,   260212 used,   756440 free,        0 buffers
KiB Swap:        0 total,        0 used,        0 free.    52300 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
    1 root      20   0   49900   3572    980 S  0.0  0.4   0:02.16 systemd
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kthreadd
    3 root      20   0       0      0      0 S  0.0  0.0   0:00.01 ksoftirqd/0
    5 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kworker/0:0H
    7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh
    9 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/0
   10 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/1
   11 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/2
   12 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/3
   13 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/4
   14 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/5
   15 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/6
   16 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/7
   17 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/8
   18 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/9
   19 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/10
   20 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/11
   21 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/12
   22 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/13
   23 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/14
   24 root      20   0       0      0      0 S  0.0  0.0   0:00.32 rcu_sched
   25 root      20   0       0      0      0 R  0.0  0.0   0:00.50 rcuos/0
   26 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/1
   27 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/2
   28 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/3
   29 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/4
   30 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/5
   31 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/6
   32 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/7
   33 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/8
   34 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/9
   35 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/10
   36 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/11
   37 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/12
   38 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuos/13

Anyone know of tricks to limit the compiler to prevent it from trying to swap? I'll add a swap partition and try again, but in the meantime... maybe there's something I could do.

unphased picture unphased  ·  16 Feb 2015

Most helpful comment

3

@Valloric - Even with YCM_CORES=1 ./install.py --clang-completer, I ended up with same error.

virtual memory exhausted: Cannot allocate memory
make[3]: *** [ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o] Error 1
make[2]: *** [ycm/CMakeFiles/ycm_core.dir/all] Error 2
make[1]: *** [ycm/CMakeFiles/ycm_support_libs.dir/rule] Error 2
make: *** [ycm_support_libs] Error 2
Traceback (most recent call last):
  File "/home/vagrant/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 266, in <module>
    Main()
  File "/home/vagrant/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 259, in Main
    BuildYcmdLibs( args )
  File "/home/vagrant/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 229, in BuildYcmdLibs
    subprocess.check_call( build_command )
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'ycm_support_libs', '--', '-j', '1']' returned non-zero exit status 2

Any hint/help?

jitendra-1217 picture jitendra-1217  ·  1 Nov 2015

All comments

2
unphased picture unphased  ·  16 Feb 2015
0

This is covered in the FAQ; you don't need a swapfile.

Valloric picture Valloric  ·  28 Feb 2015
3

@Valloric - Even with YCM_CORES=1 ./install.py --clang-completer, I ended up with same error.

virtual memory exhausted: Cannot allocate memory
make[3]: *** [ycm/CMakeFiles/ycm_core.dir/ycm_core.cpp.o] Error 1
make[2]: *** [ycm/CMakeFiles/ycm_core.dir/all] Error 2
make[1]: *** [ycm/CMakeFiles/ycm_support_libs.dir/rule] Error 2
make: *** [ycm_support_libs] Error 2
Traceback (most recent call last):
  File "/home/vagrant/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 266, in <module>
    Main()
  File "/home/vagrant/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 259, in Main
    BuildYcmdLibs( args )
  File "/home/vagrant/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 229, in BuildYcmdLibs
    subprocess.check_call( build_command )
  File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'ycm_support_libs', '--', '-j', '1']' returned non-zero exit status 2

Any hint/help?

jitendra-1217 picture jitendra-1217  ·  1 Nov 2015
0

@jitendra-1217 Have you tried the swap file suggested earlier?

vheon picture vheon  ·  1 Nov 2015
0

@vheon - No I though official wiki suggested this single job at a time solution should work. I will try that..

jitendra-1217 picture jitendra-1217  ·  1 Nov 2015
2

Ran into the same problem just now. Tried YCM_CORES=1 without success. However adding a swap file suggested did work.

domolicious picture domolicious  ·  12 Oct 2016