CLONE -Memory Leak when extending Java class with additional Ruby instance variable -----------------------------------------------------------------------------------
Key: JRUBY-4841 URL: http://jira.codehaus.org/browse/JRUBY-4841 Project: JRuby Issue Type: Bug Components: Java Integration Affects Versions: JRuby 1.5 Environment: java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode) jruby 1.5.0 (ruby 1.8.7 patchlevel 249) (2010-05-12 6769999) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java] Reporter: Tobias Vogele Assignee: Charles Oliver Nutter Priority: Critical Fix For: JRuby 1.5.1 When a Ruby class extends a Java class and has additional Ruby instance variables, it is not garbage collected. Here some code to reproduce: {code:ruby} class RubySubClass < Java::JavaLang::Object attr_accessor :javaObj end (0..50).each do |i| list = Java::JavaUtil::ArrayList.new list.add Java::JavaUtil::ArrayList.new(10000000) rs = RubySubClass.new list.add rs rs.javaObj = list java.lang.System.gc java.lang.Thread.sleep(200) puts "#{i}" end {code} On my machine this fails after the 4th iteration with: java.lang.OutOfMemoryError: Java heap space (NativeException), but the exact number of iterations of course depends on the heap size, 32/64 bit etc. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email