Last active
          July 22, 2020 07:42 
        
      - 
      
- 
        Save justdoit0823/863bc33a7964d9b3153d4b65676c16cb to your computer and use it in GitHub Desktop. 
    Linux process segment memory usage stat script.
  
        
  
    
      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
    
  
  
    
  | # total threads memory | |
| grep -A 2 'stack:' /proc/$PID/smaps|grep Rss|awk '{m += $2} END {print m}' | |
| # top ten threads | |
| grep -A 2 'stack:' /proc/$PID/smaps|grep -v -- '--'|awk '{if(index($0, "stack")) {split($NF, a, "stack:"); split(a[2], b, "]"); s[i++] = b[1]} if(index($0, "Rss")) {v[b[1]] = $2}} END {for(t in s) print s[t], v[s[t]]}'|sort -k 2 -nr|head | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment