Skip to content

Instantly share code, notes, and snippets.

@mrinterweb
Created March 10, 2011 18:33
Show Gist options
  • Save mrinterweb/864606 to your computer and use it in GitHub Desktop.
Save mrinterweb/864606 to your computer and use it in GitHub Desktop.
Find total amount of memory used by chromium/chrome
#!/usr/bin/ruby
# This script will find how much memory is currently be used by Chromium
lines = `ps aux | grep Chromium`.split(/\n/)
total_mem = 0
regex = Regexp.new('^'+("([^\s]+\s+)"*6)+'.*')
lines.each do |line|
matches = line.match(regex)
if matches
total_mem += matches[6].to_i
end
end
p "Total Mem: #{total_mem/1024}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment