Tuesday, 4 October 2011

How To Check Top Memory Usage In Unix

How To Check Top Memory Usage In Unix

·

Top or glance command can be use to monitor the overall CPU and memory usage per process. But is hard to monitor because some top command did not support sorting based on the CPU or memory consumption.

Thus, you need to use one single line of Unix command as below to detect the top 20 memory consumption process.

Memory Leak Check With Unix Command

$ UNIX95= ps-eo vsz,ruser,pid,args |sort-rn|head-20

272444 oracle 8930/opt/java1.4/bin/PA_RISC2.0/java -mx1024m

267156 oracle 8936 INVLIBR FND Concurrent_Processor MANAGE

217468 oracle 10767 FNDLIBR FND Concurrent_Processor MANAGE

216316 oracle 10774 FNDLIBR FND Concurrent_Processor MANAGE

216188 oracle 10775 FNDLIBR FND Concurrent_Processor MANAGE

215932 oracle 10776 FNDLIBR FND Concurrent_Processor MANAGE

215932 oracle 10758 FNDLIBR FND Concurrent_Processor MANAGE

215548 oracle 10763 FNDLIBR FND Concurrent_Processor MANAGE

214524 oracle 10764 FNDLIBR FND Concurrent_Processor MANAGE

214140 oracle 10777 FNDLIBR FND Concurrent_Processor MANAGE

212732 oracle 10755 FNDLIBR FND Concurrent_Processor MANAGE

212604 oracle 10778 FNDLIBR FND Concurrent_Processor MANAGE

212348 oracle 10766 FNDLIBR FND Concurrent_Processor MANAGE

212092 oracle 10765 FNDLIBR FND Concurrent_Processor MANAGE

211964 oracle 10756 FNDLIBR FND Concurrent_Processor MANAGE

211708 oracle 10773 FNDLIBR FND Concurrent_Processor MANAGE

211068 oracle 10762 FNDLIBR FND Concurrent_Processor MANAGE

210684 oracle 10754 FNDLIBR FND Concurrent_Processor MANAGE

210044 oracle 10760 FNDLIBR FND Concurrent_Processor MANAGE

209532 oracle 10779 FNDLIBR FND Concurrent_Processor MANAGE

The 3rd column is the Unix process ID which you can use as a reference before killing it.

The 1st column shows the amount of memory used by each process for data/text and stack.

This value is in pages and you need to multiply by 4096 to determine the size in byte.

After you convert the size into byte, divide it by 1024 to get value in Kb and 1024 again to get value in Mb.

It’s recommended to monitor the memory from time to time. If memory per process grow tremendously then there might be possibility of memory leak.