Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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 :
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.
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.