Finding memory Leak (ps –sort pmem)

http://hi.baidu.com/bianxuehui/item/9c43e544ea94d634fb896014


A memory leak, technically, is an ever-increasing usage of memory by an application.

With common desktop applications, this may go unnoticed, because a process typically frees any memory it has used when you close the application.

However, In the client/server model, memory leakage is a serious issue, because applications are expected to be available 24×7. Applications must not continue to increase their memory usage indefinitely, because this can cause serious issues. To monitor such memory leaks, we can use the following commands.


$ ps aux --sort pmem

$ ps aux --sort pmem USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMANDroot         1  0.0  0.0  1520  508 ?        S     2005   1:27 initinst  1309  0.0  0.4 344308 33048 ?      S     2005   1:55 agnt (idle)inst  2919  0.0  0.4 345580 37368 ?      S     2005  20:02 agnt (idle)inst 24594  0.0  0.4 345068 36960 ?      S     2005  15:45 agnt (idle)root 27645  0.0 14.4 1231288 1183976 ?   S     2005   3:01 TaskServer/bin/./wrapper-linux-x86-32

In the above ps command, –sort option outputs the highest %MEM at bottom. Just note down the PID for the highest %MEM usage. Then use ps command to view all the details about this process id, and monitor the change over time. You had to manually repeat ir or put it as a cron to a file.

 

$ ps ev --pid=27645

 

$ ps ev --pid=27645PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND

27645 ? S 3:01 0 25 1231262 1183976 14.4 /TaskServer/bin/./wrapper-linux-x86-32


Note: In the above output, if RSS (resident set size, in KB) increases over time (so would %MEM), it may indicate a memory leak in the application.

Previous articles in the Linux performance monitoring and tuning series:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值