Skip to content

Commit

Permalink
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions spec/regression/embedded_runtime_leak_spec.rb
Original file line number Diff line number Diff line change
@@ -2,16 +2,18 @@
it "should not leak runtimes after tearing them down" do
num_runtimes = 10
mbean = java.lang.management.ManagementFactory.getMemoryMXBean
num_runtimes.times do
instance = org.jruby.Ruby.newInstance
instance.evalScriptlet <<-EOS
# eat up some memory in each runtime
$arr = 500000.times.map { |i| "foobarbaz\#{i}" }
EOS
instance.tearDown(false)
# Make sure GC can keep up
while mbean.getObjectPendingFinalizationCount > 0
sleep 0.2
lambda do
num_runtimes.times do
instance = org.jruby.Ruby.newInstance
instance.evalScriptlet <<-EOS
# eat up some memory in each runtime
$arr = 500000.times.map { |i| "foobarbaz\#{i}" }
EOS
instance.tearDown(false)
# Make sure GC can keep up
while mbean.getObjectPendingFinalizationCount > 0
sleep 0.2
end
end
end.should_not raise_error
end

0 comments on commit 7862ef1

Please sign in to comment.