-
-
Save jfirebaugh/974975 to your computer and use it in GitHub Desktop.
script that shows memleak in jruby on certain windows platforms
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
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 'win32api'") | |
sc.runScriptlet("SHGetFolderPath = Win32API.new 'shell32', 'SHGetFolderPath', 'LLLLP', 'L'") | |
sc.terminate | |
sc = nil | |
} | |
end | |
i = 0 | |
puts RUBY_DESCRIPTION | |
while(true) | |
i += 1 | |
t = foo | |
JRuby.gc | |
printf "loop: %3d time: %*.4f mem: %10d\n", i, 7, t.total, Java::JavaLang::Runtime.getRuntime.totalMemory | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment