In Linux, how to tell how much memory processes are using?

前端 未结 13 1107
情歌与酒
情歌与酒 2020-11-30 17:36

I think I may have a memory leak in my LAMP application (memory gets used up, swap starts getting used, etc.). If I could see how much memory the various processes are using

13条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 18:01

    More elegant approach:

    echo "Memory usage for PID <>:"; for mem in {Private,Rss,Shared,Swap,Pss};do grep $mem /proc//smaps | awk -v mem_type="$mem" '{i=i+$2} END {print mem_type,"memory usage:"i}' ;done
    

提交回复
热议问题