Permalink
Browse files

Added line by line memory logging

  • Loading branch information...
1 parent ef23f6c commit d973db49ea082f611da8327ecc37f505c24b9e57 @binarylogic committed Oct 21, 2008
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/memory_usage_logger.rb
View
11 lib/memory_usage_logger.rb
@@ -12,4 +12,15 @@ def log_memory_usage
logger.info("Memory usage: #{memory_usage} | PID: #{$$}")
end
end
+end
+
+ActiveSupport::BufferedLogger.class_eval do
+ def add_with_memory_info(severity, message = nil, progname = nil, &block)
+ memory_usage = `ps -o rss= -p #{$$}`.to_i
+ message ||= ""
+ message += " (mem #{memory_usage})"
+ add_without_memory_info(severity, message, progname, &block)
+ end
+
+ alias_method_chain :add, :memory_info
end

0 comments on commit d973db4

Please sign in to comment.