Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Forked from jsierles/gist:208619
Created October 21, 2009 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmmanuelOga/215368 to your computer and use it in GitHub Desktop.
Save EmmanuelOga/215368 to your computer and use it in GitHub Desktop.
# Taken from passenger_memory_stats script
# Returns the private dirty RSS for the given process, in KB.
def determine_private_dirty_rss(pid)
total = 0
File.read("/proc/#{pid}/smaps").split("\n").each do |line|
line =~ /^(Private)_Dirty: +(\d+)/
if $2
total += $2.to_i
end
end
if total == 0
return nil
else
return total
end
rescue Errno::EACCES, Errno::ENOENT
return nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment