-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
Local variables which is binded by a proc is not garbage collected, if the proc is passed to java function.
Environment
jruby 9.1.0.0 (2.3.0) 2016-05-02 a633c63 Java HotSpot(TM) 64-Bit Server VM 25.151-b12 on 1.8.0_151-b12 +jit [mswin32-x86_64]
Expected Behavior
JavaClass.java
public class JavaClass
{
public JavaClass(Runnable proc)
{
proc.run();
}
}memoryleak.rb
import 'JavaClass'
class BigClass
# 100MB class
def initialize
@a = "a" * (100 * 1024 ** 2)
end
end
def func
a = BigClass.new
JavaClass.new do
puts "callback"
end
end
func
# GC by Java VisualVM
gets$ javac JavaClass.java
$ jruby-9.0.5.0/bin/jruby memoryleak.rb
run GC by jvisualvm
after running GC, memory usage is reduced about 100MB.
Actual Behavior
$ javac JavaClass.java
$ jruby-9.1.0.0/bin/jruby memoryleak.rb (9.1.0.0 or above)
run GC by jvisualvm
after running GC, memory usage is not reduced.
Reactions are currently unavailable