Thursday, January 5, 2012

Checkpoint : Finding memory Leak

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.
[Expert@splat]# ps -aux | sort -k5 -n | tail -5
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 30912 0.0 2.6 213348 55644 ? Sl 2011 0:07 in.aclientd 259
root 3783 0.0 2.6 213352 55544 ? Sl 2011 0:08 in.asessiond 0
root 30659 0.0 2.6 213436 55768 ? Sl 2011 0:08 in.ahclientd 900
root 3784 0.0 2.7 214356 56572 ? Sl 2011 0:09 in.aufpd 0
root 3504 0.0 3.1 414212 65168 ? Ssl 2011 24:32 fwd

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.

[Expert@splat1]# ps -ev 3504
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND
3504 ? Ssl 24:32 22 78 414133 65168 3.1 fwd PPKDIR=/opt/CPppak-R70 CPMDIR=/opt/CPsuite-R70/fw1 CONSOLE=/dev/console TERM=linux SUDIR=/opt/C

[Expert@splat1]# ps -ev 3504
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND
3504 ? Ssl 24:32 22 78 414133 65168 3.1 fwd PPKDIR=/opt/CPppak-R70 CPMDIR=/opt/CPsuite-R70/fw1 CONSOLE=/dev/console TERM=linux SUDIR=/opt/C

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.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.