How to find memory taken by a process using top command? | Unix Linux Forums | Red Hat

  Go Back    


Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

How to find memory taken by a process using top command?

Red Hat


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-23-2013
RHCE RHCE is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 2 July 2014, 9:24 AM EDT
Posts: 76
Thanks: 11
Thanked 0 Times in 0 Posts
How to find memory taken by a process using top command?

I wanted to know how to find the memory taken by a process using top command. The output of the top command is as follows as an example:


Code:
Mem:  13333364k total, 13238904k used,    94460k free,   623640k buffers
Swap: 25165816k total,      112k used, 25165704k free,  4572904k cached

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
16514 applmgr   25   0 2197m 1.7g  10m S  0.3 13.0  15:20.67 java
30692 crestelo  22   0 2901m 1.4g 9284 S  0.0 11.0   3:03.68 java
30431 crestelo  25   0 2043m 1.4g 161m S 50.9 11.0  79:02.73 java
30869 crestelo  25   0 2860m 1.2g 9292 S  0.0  9.6   7:11.18 java
16655 applmgr   23   0 1934m 1.1g  10m S  0.3  8.9   2:17.49 java
16319 crestelo  19   0 1541m 299m  44m S  0.0  2.3   2:52.11 java

I hope, my question is clear as to how to find the memory taken by a process using top command.

Please revert with the reply to my query.

Regards

Last edited by Scott; 01-23-2013 at 04:49 AM.. Reason: Code tags, please...
Sponsored Links
    #2  
Old 01-23-2013
parth_buch parth_buch is offline
Registered User
 
Join Date: Dec 2010
Last Activity: 14 March 2013, 6:38 AM EDT
Posts: 17
Thanks: 3
Thanked 2 Times in 2 Posts
n: %MEM -- Memory usage (RES)
A tasks currently used share of available physical memory.
Sponsored Links
    #3  
Old 01-23-2013
RHCE RHCE is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 2 July 2014, 9:24 AM EDT
Posts: 76
Thanks: 11
Thanked 0 Times in 0 Posts
Thanks for your answer but I was looking at the amount of memory taken by a process and not the % of CPU used by a process.
    #4  
Old 01-24-2013
parth_buch parth_buch is offline
Registered User
 
Join Date: Dec 2010
Last Activity: 14 March 2013, 6:38 AM EDT
Posts: 17
Thanks: 3
Thanked 2 Times in 2 Posts
%MEM is % of memory used and not % of CPU used by a process.

For knowing amount you can rely on field RES
PHP Code:
 
RES  
--  Resident size (kb)
          
The non-swapped physical memory a task has used.
          
RES CODE DATA
there are few more fields from which you can collect memory size related information...

PHP Code:
       oVIRT  --  Virtual Image (kb)
          
The  total  amount  of  virtual memory used by the task.  It includes all codedata and shared libraries plus pages that have been
          swapped out
. (Noteyou can define the STATSIZE=1 environment variable and the VIRT  will  be  calculated  from  the  /proc/#/state
          
VmSize field.)
          
VIRT SWAP RES.
       
pSWAP  --  Swapped size (kb)
          
The swapped out portion of a task‚s total virtual memory image.
       
qRES  --  Resident size (kb)
          
The non-swapped physical memory a task has used.
          
RES CODE DATA.
       
rCODE  --  Code size (kb)
          
The amount of physical memory devoted to executable codealso known as the ‚text resident set‚ size or TRS.
       
sDATA  --  Data+Stack size (kb)
          
The amount of physical memory devoted to other than executable codealso known as the ‚data resident set‚ size or DRS.
       
tSHR  --  Shared Mem size (kb)
          
The amount of shared memory used by a task.  It simply reflects memory that could be potentially shared with other processes
Sponsored Links
    #5  
Old 01-24-2013
RHCE RHCE is offline
Registered User
 
Join Date: Dec 2012
Last Activity: 2 July 2014, 9:24 AM EDT
Posts: 76
Thanks: 11
Thanked 0 Times in 0 Posts
I was wondering how to get the options for SWAP, CODE. Can you please give the syntax to give with the top command?
Sponsored Links
    #6  
Old 02-26-2013
nixsavy nixsavy is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 18 April 2013, 6:34 PM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
For top command

To sort process as per swap page usage

Capital O followed by p (small p) andthen Enter key

not this is wat or something other u look
Sponsored Links
    #7  
Old 02-27-2013
rbatte1 rbatte1 is offline Forum Staff  
Moderator
 
Join Date: Jun 2007
Last Activity: 26 July 2014, 5:24 PM EDT
Location: Lancashire, UK
Posts: 1,612
Thanks: 513
Thanked 275 Times in 246 Posts
Would the output of ps do the trick?

Code:
ps -lp $PID

Column 10 has the memory size allocated.


Code:
ps -lp $$
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
4 S  7006 10701 10700  0  80   0 - 26772 wait   pts/9    00:00:00 ksh

This has my shell process being 26,772Kb


Robin
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Free memory in top and prstat command eiga Solaris 3 05-14-2010 01:56 PM
Command to find the Memory and CPU utilization using 'top' command ananthi_ku Shell Programming and Scripting 2 01-11-2010 09:41 AM
Command to find TOP 5 Memory consuming process bce_groups AIX 4 05-07-2009 05:09 PM
how can i extract only the Memory line from top command ? umen Shell Programming and Scripting 1 02-13-2007 09:46 AM
unix top command (memory usage) gfhgfnhhn UNIX for Advanced & Expert Users 2 03-17-2006 07:33 AM



All times are GMT -4. The time now is 06:31 PM.