Skip to content

Instantly share code, notes, and snippets.

@munkyboy
Created December 22, 2010 01:59
Show Gist options
  • Save munkyboy/750957 to your computer and use it in GitHub Desktop.
Save munkyboy/750957 to your computer and use it in GitHub Desktop.
script that shows memleak in jruby on certain windows platforms
require 'java'
require 'benchmark'
def foo
Benchmark.measure {
sc = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::SINGLETHREAD, org.jruby.embed.LocalVariableBehavior::TRANSIENT)
sc.runScriptlet("require 'rubygems'")
sc.terminate
sc = nil
}
end
i = 0
puts RUBY_DESCRIPTION
while(true)
i += 1
t = foo
printf "loop: %3d time: %*.4f mem: %10d\n", i, 7, t.total, Java::JavaLang::Runtime.getRuntime.totalMemory
JRuby.gc
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment