Skip to content

Instantly share code, notes, and snippets.

@griff
Created June 8, 2010 13:53
Show Gist options
  • Save griff/430032 to your computer and use it in GitHub Desktop.
Save griff/430032 to your computer and use it in GitHub Desktop.
A small jruby program that slams the PermGen
class BugTest
def run
puts "Hey"
end
end
# Wait so I can attach VisualVM to inspect
puts "Press enter to begin"
gets
i = 1
while true
e = Java::RealData.new
# Every instance of BugTest creates a new class in a ClassLoader that doesn't get garbage collected
e.setErrors(BugTest.new)
# Nice little instance counter for some feedback
if (i % 1000) == 0
puts i
end
i += 1
end
public class RealData
{
// Works with any interface
private Runnable errors;
public void setErrors(Runnable errors)
{
this.errors = errors;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment