Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed Sep 11, 2008
0 parents commit 8c22b44
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2008 Ben Johnson of Binary Logic (binarylogic.com)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 changes: 10 additions & 0 deletions README.mdown
@@ -0,0 +1,10 @@
# Memory usage logger

This is linux specific. The following command retrieves the memory:

memory_usage = `ps -o rss= -p #{$$}`.to_i

The reason I created this was to help track down a memory leak. It worked very well because it adds the process id and memory usage in with each rails request. This way, if you have a cluster, you can monitor each process and scroll through your logs and watch the memory. If it suddenly starts to jump you can look at the request and at least you have a starting point. You can checkout the code for that specific controller action and try to narrow it down.


Copyright (c) 2007 Ben Johnson of [Binary Logic](http://www.binarylogic.com), released under the MIT license
1 change: 1 addition & 0 deletions init.rb
@@ -0,0 +1 @@
require "memory_usage_logger"
12 changes: 12 additions & 0 deletions lib/memory_usage_logger.rb
@@ -0,0 +1,12 @@
module BinaryLogic
module MemoryUsageLogger
private
def rendering_runtime(*args)
msg = super
memory_usage = `ps -o rss= -p #{$$}`.to_i
msg + " | PID: #{$$} | Memory Usage: #{memory_usage}"
end
end
end

ActionController::Base.send(:include, BinaryLogic::MemoryUsageLogger)

0 comments on commit 8c22b44

Please sign in to comment.