From 3d7e6f530eb4c90fec7bf92fb116c2d11dc160ee Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 25 Jul 2011 11:27:37 +0100 Subject: Add a flag to turn off logging memory usage, as (a) this is a debug setting, and (b) it's not cross-platform anyway (causes issues for people developing on OS X) --- app/controllers/application_controller.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 405327952..fe9ed7ec7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -46,12 +46,17 @@ class ApplicationController < ActionController::Base # egrep "CONSUME MEMORY: [0-9]{7} KB" production.log around_filter :record_memory def record_memory - File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) - rss_before_action = $1.to_i - yield - File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) - rss_after_action = $1.to_i - logger.info("PID: #{Process.pid}\tCONSUME MEMORY: #{rss_after_action - rss_before_action} KB\tNow: #{rss_after_action} KB\t#{request.url}") + record_memory = MySociety::Config.get('DEBUG_RECORD_MEMORY', false) + if record_memory + File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) + rss_before_action = $1.to_i + yield + File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) + rss_after_action = $1.to_i + logger.info("PID: #{Process.pid}\tCONSUME MEMORY: #{rss_after_action - rss_before_action} KB\tNow: #{rss_after_action} KB\t#{request.url}") + else + yield + end end # Set cookie expiry according to "remember me" checkbox, as per "An easier -- cgit v1.2.3