技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 系统运维 --> 使用Smem精确显示Linux下内存使用情况

使用Smem精确显示Linux下内存使用情况

浏览:975次  出处信息

   使用Smem精确显示Linux下内存使用情况

   

   smem 能够为你报告内存的占用情况,提供 PID、User、Command、Swap、USS、PSS、RSS 等信息。

   除了一般的文本信息报告外,smem 也可以生成条状或饼状图。

项目地址

   https://www.selenic.com/smem/

安装

   smem 要求 Kernel 2.6.27以上并且Python 2.4 及以上版本、绘图功能依赖matplotlib 库。

   可以使用yum或者apt直接安装。

  • yum install smem

smem的基本使用

a.    默认情况下不加任何参数,显示所有进程的内存使用情况

  • [root@BJ-BX-129-182 ~]#smem

  •  PID User     Command                         Swap      USS      PSS      RSS

  • 1530 root     /sbin/mingetty /dev/tty1           0       68       98      536

  • 1532 root     /sbin/mingetty /dev/tty2           0       68       98      536

  • 1547 root     /sbin/mingetty /dev/tty6           0       68       98      536

  • Output Omited...

  • 17142 root     /home/app/open-falcon/dashb        0    13092    14087    19800

  • 17139 root     /home/app/open-falcon/dashb        0    13104    14093    19800

  • 17138 root     /home/app/open-falcon/dashb        0    13224    14215    19920

  • 17145 root     /home/app/open-falcon/dashb        0    13468    14470    20184

  • 13593 mysql    /usr/libexec/mysqld --based        0    28716    29089    30276

  • [root@BJ-BX-129-182 ~]#

b.    -w参数,显示内存的整体使用情况

  • [root@BJ-BX-129-182 ~]#smem -w

  • Area                           Used      Cache   Noncache

  • firmware/hardware                 0          0          0

  • kernel image                      0          0          0

  • kernel dynamic memory       2501892    2414344      87548

  • userspace memory             236364      40848     195516

  • free memory                 1186788    1186788          0

  • [root@BJ-BX-129-182 ~]#

c.    -p参数,显示内存使用百分比,-u按照用户显示

  • [root@BJ-BX-129-182 ~]#smem -up

  • User     Count     Swap      USS      PSS      RSS

  • postfix      2    0.00%    0.07%    0.10%    0.18%

  • redis        1    0.00%    0.16%    0.17%    0.18%

  • mysql        1    0.00%    0.73%    0.74%    0.77%

  • root        36    0.00%    4.73%    5.04%    6.76%

  • [root@BJ-BX-129-182 ~]#

内存 VSS,RSS,PSS,USS的区别

   VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)

   RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)

   PSS - Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)

   USS - Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存)

   一般来说内存占用大小有如下规律:VSS >= RSS >= PSS >= USS

   

   

   

   

参考文章

   http://myeyeofjava.iteye.com/blog/1837860

   http://www.jianshu.com/p/b1c2b8bdec26

QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
<< 前一篇:linux 之 mv
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1