Operating System - HP-UX
1825950 Members
2849 Online
109690 Solutions
New Discussion

Re: Memory usage based sorting using top

 
SOLVED
Go to solution
Tapan Shah
Honored Contributor

Memory usage based sorting using top

Hi All,

By default "top" command gives the process list sorted (descending) on CPU usage. I want to know if there is any way to make the tool print the process list sorted on memory usage.

If not using top, can I use any other command/utility to get this required output?

Is it possible to have all the statistics (like CPU usage and Mem. usage) for a single process using top?

Thanks for any help in this.

Regards,
Tapan.
5 REPLIES 5
Arunvijai_4
Honored Contributor

Re: Memory usage based sorting using top

Hi Tapan,

You can use UNIX95 variable with ps.

UNIX95= ps -efH


-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor
Solution

Re: Memory usage based sorting using top

Hi Tapan,

Sorry for the second post, check this thread and take a look at Geoff's script

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=838754

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Muthukumar_5
Honored Contributor

Re: Memory usage based sorting using top

Use like,

UNIX95=1 ps -ef -o pid,sz,vsz,comm

sz and vsz will give memory related informations.

You can use glance tool for accurate informations.

--
Muthu
Easy to suggest when don't know about the problem!
Matthew Ghofrani
Regular Advisor

Re: Memory usage based sorting using top

Try this. It sorts all ps items with highest memory listed first. The memory is in page units. In my system every page is 4K.

#!/usr/bin/sh
# *******
ps -elf|awk '{print $10, $3, $4, $15, 16}'|sort -nr|more
exit
Life is full of bugs
Bill Hassell
Honored Contributor

Re: Memory usage based sorting using top

The man page for top tells all -- no option for memory usage. top is designed to show the top processes using CPU cycles. You can use ps to report memory usage but if you search through these Forums, you'll see many requests for this information with cautions that trying to figure out all memory usage is a lot more complicated. If you just want to see the largest processes, you can use this command:

UNIX95=1 ps -e -o vsz,pid,ppid,args | sort -rn | head -20

Otherwise, be aware that programs share a number of memory areas such as libraries, text, data (shared memory segmants) and the buffer cache.



Bill Hassell, sysadmin