Created
August 4, 2015 15:23
-
-
Save bbrowning/3cbb3901d4facd7fc99f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num_runtimes = 10 | |
puts "Creating runtimes..." | |
num_runtimes.times do | |
instance = org.jruby.Ruby.newInstance | |
instance.evalScriptlet <<-EOS | |
require "socket" | |
server = TCPServer.new(0) | |
Thread.new do | |
begin | |
server.accept | |
rescue Exception => ex | |
end | |
end | |
Thread.new do | |
sleep 1 | |
JRuby.runtime.tearDown(false) | |
end | |
EOS | |
end | |
puts "Waiting for runtimes to teardown..." | |
sleep 5 | |
mbean = java.lang.management.ManagementFactory.getThreadMXBean | |
threads = mbean.getThreadInfo(mbean.getAllThreadIds) | |
thread_names = threads.map(&:thread_name) | |
leaked_runtimes = thread_names.select do |name| | |
name =~ /Ruby-\d+-Thread-\d+/ | |
end | |
puts "Created #{num_runtimes} JRuby runtimes and #{leaked_runtimes.size} " + | |
"leaked waiting on a selector" | |
exit 1 if leaked_runtimes.size > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# JRuby 1.7.21 | |
$ jruby jruby_selector_leak.rb | |
Creating runtimes... | |
Waiting for runtimes to teardown... | |
Created 10 JRuby runtimes and 10 leaked waiting on a selector | |
# JRuby 9.0.0.0 | |
$ jruby jruby_selector_leak.rb | |
Creating runtimes... | |
Waiting for runtimes to teardown... | |
Created 10 JRuby runtimes and 10 leaked waiting on a selector | |
# JRuby 9.0.1.0-SNAPSHOT + selector leak patch | |
$ jruby jruby_selector_leak.rb | |
Creating runtimes... | |
Waiting for runtimes to teardown... | |
Created 10 JRuby runtimes and 0 leaked waiting on a selector |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment