Skip to content

Xmx limited to 500m on JRuby 9.3.x with 2.x #52

@seanstory

Description

@seanstory

Description

I've observed that jruby-launcher 2.0.1 is causing installations of JRuby 9.3.x.x to be limited to 500 MB of heap. This cannot be overridden with JAVA_OPTS or JRUBY_OPTS. Attempting to do wso will result in a ps aux like:

seanstory        70590   0.0  0.4 413864832 246672 s001  S+   12:51PM   0:04.51 java -Xmx1g -client -Xmx500m -Xss2048k -Djffi.boot.library.path=/opt/homebrew/Cellar/rbenv/1.3.2/versions/jruby-9.3.15.0/lib/jni -Dfile.encoding=UTF-8 -Xbootclasspath/a:/opt/homebrew/Cellar/rbenv/1.3.2/versions/jruby-9.3.15.0/lib/jruby.jar -classpath : -Djruby.home=/opt/homebrew/Cellar/rbenv/1.3.2/versions/jruby-9.3.15.0 -Djruby.lib=/opt/homebrew/Cellar/rbenv/1.3.2/versions/jruby-9.3.15.0/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main /opt/homebrew/opt/rbenv/versions/jruby-9.3.15.0/bin/irb

Note both the -Xmx1g (expected) and the -Xmx500m (unexpected).

This does not appear to be an issue with JRuby versions 9.4.x.x.

I found a reference to 500m here: https://github.com/jruby/jruby/blob/0db23ddd14b02c90f37c9161b0ca76aee57c6b35/bin/jruby.sh#L113-L115 which is present in the jruby.sh files in 9.3.x.x. I expect therefore that this bug is related to rbenv/ruby-build#2517

Reproduction Steps

  1. brew install rbenv
  2. rbenv install jruby-9.3.14.0
  3. create a file, test.rb, with contents puts Java::JavaLangManagement::ManagementFactory.memory_mx_bean.heap_memory_usage.max / 1024 / 1024
  4. run JAVA_OPTS="-Xmx1g" ruby test.rb, and see output ~500
  5. install instead jruby-9.4.12.0
  6. execute JAVA_OPTS="-Xmx1g" ruby test.rb, see expected default output of ~1024

Workarounds

  • uninstall jruby-launcher: gem uninstall jruby-launcher
  • replace jruby-launcher with an older verion: gem uninstall jruby-launcher -v 2.0.1 && gem install jruby-launcher -v 1.1.19
  • set heap instead with JAVA_MEM environment variable: export JAVA_MEM="-Xmx=1g"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions