remove jmx_enabled option that causes memory leak#2
Open
nicobrevin wants to merge 1 commit intotomdz:masterfrom
Open
remove jmx_enabled option that causes memory leak#2nicobrevin wants to merge 1 commit intotomdz:masterfrom
nicobrevin wants to merge 1 commit intotomdz:masterfrom
Conversation
Author
|
I've got a manual test case to reproduce, just in case you're interested: # memory-leak.rb
require 'rubygems'
require 'rack'
require 'slf4j-api'
require 'metrics-core'
require 'metrics-annotation'
require 'jruby-rack-metrics'
leaky = true
if ! leaky
com.yammer.metrics.reporting.JmxReporter.startDefault(com.yammer.metrics.Metrics.defaultRegistry)
end
app = Rack::Builder.new do
use JrubyRackMetrics::Monitor, :jmx_enabled => leaky
run (proc do |env|
# the more possible statuses, the more metrics in each jmxreporter, so
# the quicker this will die
possibles = [200, 302, 404, 503]
status = possibles[rand(possibles.length)]
[status, {"Content-Type" => "text/html"}, "Hello Rack!"]
end)
end
Rack::Handler.get('webrick').run(app)Run this like so:
And in another window, run apache bench:
Once it is running, hook up |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've noticed that using the jmx_enabled option causes a memory leak. Each request creates a new JmxReporter, which is registered with the MetricsRegistry and never removed.
This commit takes away the jmx_enabled option in exchange for helper methods that let you set up a default jmx reporter during rack up or however you initialise your application.