How to fix RVM exhausting Virtual Memory on VPS?

I’m trying to install ruby via RVM on an Ubuntu VPS with only 512 MB memory.

When running rvm install 1.9.3 I get the error:

ERROR: Error running 'make ', please read /home/matt/.rvm/log/ruby-1.9.3-p0/make.log

In the log file is the following:

[2012-01-01 03:34:26] make 
    CC = gcc
    LD = ld
    LDSHARED = gcc -shared
    CFLAGS = -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=poi
nter-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration  -fPIC
    XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
    CPPFLAGS =   -I. -I.ext/include/x86_64-linux -I./include -I.
    DLDFLAGS = -Wl,-soname,libruby.so.1.9  
    SOLIBS = -lpthread -lrt -ldl -lcrypt -lm  
compiling parse.c
virtual memory exhausted: Cannot allocate memory
make: *** [parse.o] Error 1

Is there a way I can tell rvm to limit the amount of memory it uses for compiling?

Answer

Make sure you have adequate swap space. You can also try removing the -O3 and hoping for the best. Do you know what VPS software they’re using?

Attribution
Source : Link , Question Author : Matt McCormick , Answer Author : David Schwartz

Leave a Comment