Ben Browning created JRUBY-6456: ----------------------------------- Summary: ThreadLocal Leak in 1.9 Mode w/ Internal Recursive Map Key: JRUBY-6456 URL: https://jira.codehaus.org/browse/JRUBY-6456 Project: JRuby Issue Type: Bug Affects Versions: JRuby 1.6.6 Reporter: Ben Browning Assignee: Thomas E Enebo Fix For: JRuby 1.6.7
Anything that triggers the recursiveListAccess method of org.jruby.Ruby to get called (Array.hash, Array.join, others in 1.9 mode) leaks ThreadLocal variables. The amount of memory leaked is based on the number of threads triggering this method per runtime and the number of different method names .hash, .join, etc get called inside of. A simple program to illustrate: {code:title=thread_local_leak.rb|borderStyle=solid} require 'java' COUNT = 100 class ThreadLocalLeak < Array COUNT.times do |i| define_method("hash_#{i}") do hash end end end leaker = ThreadLocalLeak.new([5, 10, 15]) COUNT.times { |i| leaker.send("hash_#{i}") } recursiveField = JRuby.runtime.java_class.declared_field("recursive") recursiveField.accessible = true size = recursiveField.value(JRuby.runtime).get.size puts "COUNT = #{COUNT}, recursive field size = #{size}" {code} {code:title=output|borderStyle=solid} bbrowning@bbrowning-mbp:~/tmp$ jruby -v jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java] bbrowning@bbrowning-mbp:~/tmp$ jruby --1.9 thread_local_leak.rb COUNT = 100, recursive field size = 100 {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.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