I recently discovered that I get memory bursts when I experience 500 error code in my Rails applications (I run several and experience the same thing). I found out using Scout, and every time I had a 500 error, I saw a sample of memory leaks (almost). Below is the most recent example:
![enter image description here](https://fooobar.com//img/6a89a055f893ae5ec399b08d5de84089.png)
Although the graph shows that exception_notification does not have a large amount of memory, but rather "Middleware". The only middleware that I use (as far as I know) is the exception notification ( gem '[exception_notification][2]'
v. 4.2.1), so I assume that this should be it, and that only my interpretation is incorrect.
Edit after comment by Alexis - I ran:
Rails.configuration.middleware.each do |m|
puts "use #{m.inspect}"
end;0
:
use UTF8Cleaner::Middleware
use Rack::Sendfile
use ActionDispatch::Static
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x0055f8e1dd5a60>
use Rack::Timeout
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use Airbrake::Rack::Middleware
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use ExceptionNotification::Rack
use Rakismet::Middleware
use ScoutApm::Middleware
Airbrake ScoutApm , .
My production.rb :
config.middleware.use ExceptionNotification::Rack, :email => {
:email_prefix => "[MyApp.se Exception] ",
:sender_address => %{"Exception Notifier" <support@myapp.se>},
:exception_recipients => %w{me@myapp.se}
}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => false,
:return_response => true,
:raise_delivery_errors => true,
:address => 'smtp.myapp.se',
:port => 587,
:domain => "myapp.se",
:user_name => 'mailer@myapp.se',
:password => ENV['MAILER_PWD'],
:authentication => 'plain'
}
Great Memory Bloat Hunt , , , , , - .
? , , ? Rails ?