Last active
December 12, 2015 00:48
-
-
Save fabrizioc1/4686339 to your computer and use it in GitHub Desktop.
Estimate Linux process memory usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# can probably cross reference with ltrace | |
# this removes shared libraries from the total memory count | |
def memory_estimate(pid) | |
`sudo pmap #{pid}`.lines.reject{|line| | |
line[%r[/lib[^.]+\.so]] or line[/^ total/] | |
}.drop(1).reduce(0){|total,line| | |
total + line.match(/(\d+)K/)[1].to_i | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment