JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6654

Using ruby's standard gserver library causes jruby to run out of memory

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.7
    • Fix Version/s: JRuby 1.7.0.pre1
    • Labels:
    • Environment:
      32 bit windows XP environment with maxed out ram
      jruby -v
      jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM 1.6.0_30) [Windows XP-x86-java]
    • Number of attachments :
      1

      Description

      When using a simple TCP/IP server derived from ruby's standard GServer jruby will run out of memory. MRI ruby will not. I could not find any combination of the following java arguments to alleviate the problem:

      -XX:MaxPermSize=256M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Xmx512m -Xms256m
      

      on my box the +HeapDumpOnOutOfMemoryError will motivate the generation of the hprof file in 6-8 minutes every time. I moved the code to an 8 gig 64 bit windows 7 box. The issue still occurs but takes longer (I do increase the memory amounts).

      Launching via jruby or 'java -server -jar .\lib\jars\jruby-complete-1.6.7.2.jar' makes no difference. Only launching via mri ruby resolves the issue.

      The issue was originally detected in 1.6.5 and I upgraded jruby to see if the issue went away (It did not).

      To see the issue launch as follows:

      jruby mem_test.rb
      

      then launch

      jruby mem_test_client.rb
      

      I am desperate for a fix as we are trying to port our MRI based rails 2.3.x environment to jruby/Rails 3.2.3 and we have an internal tcp/ip server causing total lockup.

      Thanks!

      Cris

        Activity

        Hide
        Hiro Asari added a comment -

        I tested this on my Mac OS X laptop.

        1. mem_test.rb is missing a closing single quote on line 23.
        2. Can you test your application on the master branch? http://ci.jruby.org/snapshots/master/ I tested it against the master, but I did not observe the kind of memory usage that might lead to OOM exception. (Namely, heap is used up--up to 350 MB, but GC did the job well, collecting all but 36 MB; most of it was used by int[], up to 80%.)
        3. When you do get a heap dump, can you see what's taking up memory?
        Show
        Hiro Asari added a comment - I tested this on my Mac OS X laptop. mem_test.rb is missing a closing single quote on line 23. Can you test your application on the master branch? http://ci.jruby.org/snapshots/master/ I tested it against the master, but I did not observe the kind of memory usage that might lead to OOM exception. (Namely, heap is used up--up to 350 MB, but GC did the job well, collecting all but 36 MB; most of it was used by int[] , up to 80%.) When you do get a heap dump, can you see what's taking up memory?
        Hide
        Cris Shupp added a comment -

        I have researched this further and I can now eliminate gserver entirely.
        The problem occurs when using backticks or system and only in a very unusual way.
        The very simple script, when run on my 32 bit windows box, will run out of memory with 1.6.7.2 if a call is made to jruby.
        When run on the version you asked me to install:
        jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-05-11 1c1ccb5) (Java HotSpot(TM) Client VM 1.6.0_30) [Windows XP-x86-java]

        The problem completely disappears. See the sample script below. If the marked lines are present I can watch memory grow in 5 meg chunks (but not under the dev version). Is this bug worth closing?

        #########################BEGIN RUBY###############################
        while (true) do
        #puts `c:\\Java\\jdk1.6.0_30\\bin
        java -jar ../lib/jars/jruby-complete-1.6.7.2.jar -e "puts Time.now.to_s"` #OK
        puts `c:\\Java\\jdk1.6.0_30\\bin
        java -jar ../lib/jars/jruby-complete-1.6.7.2.jar time.rb` #OK
        #puts `jruby -e 'puts Time.now.to_s'` #bombs out of memory
        #puts `jruby time.rb` #bombs out of memory
        #puts `echo %time%` #OK
        end
        #########################END RUBY###############################

        Show
        Cris Shupp added a comment - I have researched this further and I can now eliminate gserver entirely. The problem occurs when using backticks or system and only in a very unusual way. The very simple script, when run on my 32 bit windows box, will run out of memory with 1.6.7.2 if a call is made to jruby. When run on the version you asked me to install: jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-05-11 1c1ccb5) (Java HotSpot(TM) Client VM 1.6.0_30) [Windows XP-x86-java] The problem completely disappears. See the sample script below. If the marked lines are present I can watch memory grow in 5 meg chunks (but not under the dev version). Is this bug worth closing? #########################BEGIN RUBY############################### while (true) do #puts `c:\\Java\\jdk1.6.0_30\\bin java -jar ../lib/jars/jruby-complete-1.6.7.2.jar -e "puts Time.now.to_s"` #OK puts `c:\\Java\\jdk1.6.0_30\\bin java -jar ../lib/jars/jruby-complete-1.6.7.2.jar time.rb` #OK #puts `jruby -e 'puts Time.now.to_s'` #bombs out of memory #puts `jruby time.rb` #bombs out of memory #puts `echo %time%` #OK end #########################END RUBY###############################
        Hide
        Hiro Asari added a comment -

        Hi, Cris,

        Thank you for checking. It is good to know that the master is OK.

        Since I (personally) do not anticipate another 1.6.x release, I'm going to resolve this.

        Show
        Hiro Asari added a comment - Hi, Cris, Thank you for checking. It is good to know that the master is OK. Since I (personally) do not anticipate another 1.6.x release, I'm going to resolve this.

          People

          • Assignee:
            Hiro Asari
            Reporter:
            Cris Shupp
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: