Search code examples
javamemorysizeheap-memoryjruby

JRUBY JAVA HEAP SPACE out of memory error


How can I adjust the Java heap memory?
I already tried

jruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m -S rails s

but it didn't work


Solution

  • The memory argument should be like:

    -Xms1024m - the init memory allocate when the JVM start
    -Xmx2048m - the max memory that the JVM can allocate
    

    Also use:

    -XX:MaxNewSize - it could be 30% of the Xmx value:
    

    -XX:MaxNewSize (in JDK1.3 and JDK1.4) or -Xmn (new name of Young Generation flag from JDK1.4 onwards). Increasing the -Xmn (Young Generation Area) helps in scenarios where the Application creates short living objects (less caching Applications), because it increases the time of minor GC, most of the application objects dies early.

    Note: you can put your won values.