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

JRuby's JIT will eventually blow permgen space; use other mechanisms to allow old methods to be garbage-collected

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 0.9.9
    • Fix Version/s: JRuby 1.0.0RC3
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      1

      Description

      JRuby's JIT create a lot of new classes, which in certain scenarios could result in permgen space being gobbled up until it's all gone. This is because individual classes can't be collected in Java unless the classloader they're associated with gets collected.

      The attached patch modifies the JIT and the class-generation code in JRuby to use a specified classloader. In the case of JITted code, this would be a new classloader per method compiled, allowing those methods to be collected.

      With it, the following code runs indefinitely without ever using up permgen:

      while true
        def hello; end
        hello
      end
      

      The patch could use some more eyes, but it seems to work well enough. Of course, the memory overhead caused by classloader-per-method is a whole other issue.

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        This has been in trunk for a few weeks, and it's looking good. I don't like the overhead of a classloader-per-class, but there's not really another way under JVM right now.

        Show
        Charles Oliver Nutter added a comment - This has been in trunk for a few weeks, and it's looking good. I don't like the overhead of a classloader-per-class, but there's not really another way under JVM right now.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Charles Oliver Nutter
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: