Finding the most memory consuming processes in Linux


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Finding the most memory consuming processes in Linux
# 1  
Old 12-31-2013
Finding the most memory consuming processes in Linux

Platform: Oracle Linux 6.4


To find the most memory consuming processes, I tried the following 2 methods


1. Method1

Code:
# ps aux | head -1 ; ps aux | sort -nk +4 | tail -7
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        95  0.0  0.0      0     0 ?        S    Nov14   0:37 [ksoftirqd/22]
root        96  0.0  0.0      0     0 ?        S    Nov14   0:14 [watchdog/22]
root        97  0.0  0.0      0     0 ?        S    Nov14   0:00 [migration/23]
root        99  0.0  0.0      0     0 ?        S    Nov14   0:28 [ksoftirqd/23]
rpc      45927  0.0  0.0  19020   636 ?        Ss   Nov14   0:04 rpcbind
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root     44842  0.3  0.1 5843388 376616 ?      Sl   Nov14 209:35 /grid/product/11.2.0/jdk/jre/bin/java ...
#

Method2. Using top command.

Execute top command, then type SHIFT + o and you'll get the following menu

Code:
Current Sort Field:  K  for window 1:Def
Select sort field via field letter, type any other key to return

  a: PID        = Process Id
  b: PPID       = Parent Process Pid
  c: RUSER      = Real user name
  d: UID        = User Id
  e: USER       = User Name
  f: GROUP      = Group Name
  g: TTY        = Controlling Tty
  h: PR         = Priority
  i: NI         = Nice value
  j: P          = Last used cpu (SMP)
* K: %CPU       = CPU usage
  l: TIME       = CPU Time
  m: TIME+      = CPU Time, hundredths
  n: %MEM       = Memory usage (RES)
  o: VIRT       = Virtual Image (kb)
  p: SWAP       = Swapped size (kb)
  q: RES        = Resident size (kb)
  r: CODE       = Code size (kb)
  s: DATA       = Data+Stack size (kb)
  t: SHR        = Shared Mem size (kb)
  u: nFLT       = Page Fault count
  v: nDRT       = Dirty Pages count
  w: S          = Process Status
  x: COMMAND    = Command name/line
  y: WCHAN      = Sleeping in Function
  z: Flags      = Task Flags <sched.h>

Now type n and enter.

I followed the above steps and I got the following output.

Code:
7481 oracle    20   0 4546m 1.5g 1.5g S  0.0  4.8  11:09.05 ora_dbw0_BRBOPRD3
11702 oracle    20   0 4537m 1.5g 1.5g S  0.0  4.7   9:43.97 oracleBRBOPRD3 (LOCAL=NO)
11709 oracle    20   0 4539m 1.5g 1.5g S  0.0  4.7   6:31.47 oracleBRBOPRD3 (LOCAL=NO)
11667 oracle    20   0 4537m 1.4g 1.4g S  0.0  4.4   7:12.83 oracleBRBOPRD3 (LOCAL=NO)
11638 oracle    20   0 4537m 1.4g 1.4g S  0.0  4.4   7:29.32 oracleBRBOPRD3 (LOCAL=NO)
11696 oracle    20   0 4537m 1.4g 1.4g S  0.2  4.3   8:26.55 oracleBRBOPRD3 (LOCAL=NO)
11771 oracle    20   0 4537m 1.3g 1.3g S  0.0  4.2   5:41.32 oracleBRBOPRD3 (LOCAL=NO)
11657 oracle    20   0 4537m 1.3g 1.3g S  0.0  4.1   6:03.84 oracleBRBOPRD3 (LOCAL=NO)
11735 oracle    20   0 4539m 1.3g 1.3g S  0.0  4.0   5:40.87 oracleBRBOPRD3 (LOCAL=NO)
11707 oracle    20   0 4539m 1.3g 1.3g S  0.0  4.0   5:46.76 oracleBRBOPRD3 (LOCAL=NO)
11728 oracle    20   0 4537m 1.2g 1.2g S  0.0  3.9   5:22.02 oracleBRBOPRD3 (LOCAL=NO)
11673 oracle    20   0 4537m 1.2g 1.2g S  0.0  3.8   5:22.36 oracleBRBOPRD3 (LOCAL=NO)
11229 oracle    20   0 4539m 1.2g 1.2g S  0.0  3.8   5:03.04 oracleBRBOPRD3 (LOCAL=NO)
11661 oracle    20   0 4537m 1.2g 1.2g S  0.0  3.8   5:13.54 oracleBRBOPRD3 (LOCAL=NO)

As you can see the outputs from Method1 and Method2 are different ? Which is the accurate one ?

Last edited by Scott; 12-31-2013 at 06:27 AM.. Reason: Truncated long command for better readability on mobile devices
# 2  
Old 12-31-2013
Not sure if you are comparing the right columns. Trying to replicate your approach, I got:
Code:
ps aux | sort -nrk4,4 | awk '{print $5/1024} NR>4 {exit}'
1236.18
907.668
212.672
624.902
583.66
top -n1 | awk 'NR>7 {print $6} NR>11 {exit}'
1236m
907m
212m
624m
583m

# 3  
Old 01-03-2014
First, you need to clarify what you want to know: every process uses some amount of memory, of which some might be located in (real) memory and some might be located in the swap (virtual memory). Do you want to know the "biggest" process in terms of real memory consumption (only the parts in real memory count), in terms of virtual memory consumption (somewhat misleading, the totals of real memory and swapped-out-memory count) or swap allocation (only the swapped amount counts)?

For instance: a process holds 3GB of memory, of which 1GB is swapped out. Would you like to get "1" (the swapped amount), "2" (the real mem amount) or "3" (the total amount) reported for it?

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Which process was consuming most memory in the Past?

Hello There are options / commands to check which process is consuming maximum memory However is there any command/mechanism which will tell us which process was consuming maximum memory in specific time interval in the past? I heard nmon report can help in this regard. is there any... (5 Replies)
Discussion started by: Chetanz
5 Replies

2. Shell Programming and Scripting

Unix shell script to query linux top consuming processes

Hi All, O/S: Linux 86x64 Red Hat I have a sql script that queries top consuming processes of Linux using TOP commnd. Now I need to automate this task and pass the top processes i.e., PID to the sql script through unix shell script. Could anyone please let me know how to achieve this. ... (2 Replies)
Discussion started by: a1_win
2 Replies

3. Shell Programming and Scripting

Discrepancy in finding the top memory consuming processes

When I run 'top' command,I see the following Memory: 32G real, 12G free, 96G swap free Though it shows as 12G free,I am not able to account for processes that consume the rest 20G. In my understanding some process should be consuming atleast 15-16 G but I am not able to find them. Is... (1 Reply)
Discussion started by: prasperl
1 Replies

4. Shell Programming and Scripting

Warning in Top 10 cpu consuming processes

I m using following command to find top 10 cpu consuming processes. However whenever i execute the command i get following warning. What can be done to avoid it? # ps -auxf | sort -nr -k 3 | head -10 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ root ... (6 Replies)
Discussion started by: pinga123
6 Replies

5. UNIX for Advanced & Expert Users

AIX: Finding processes attached to shared memory

Is there some way to tell what processes are attached to a shared memory segment? We have a system on which I perform "icps -ma" and there are several segments pending deletion having numerous processes attached to them and I can't tell what processes they are. Neither the creator's pid nor last... (7 Replies)
Discussion started by: DreamWarrior
7 Replies

6. Shell Programming and Scripting

Finding the age of a unix process, killing old processes, killing zombie processes

I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time. Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies

7. AIX

Command to find TOP 5 Memory consuming process

HI All, Can anyone send me a command to find TOP 5 Memory consuming process. It would be lelpful if I get output something like below processname - pid - memory(in MB) - command I tried few commands from the internet but the result only give the real memory usage or pagging, I want total... (4 Replies)
Discussion started by: bce_groups
4 Replies

8. AIX

Process consuming most memory

How can i find the processes that is consuming most memory? I tried TOPAS and SVMON and this didn't gave me the desired result. (1 Reply)
Discussion started by: shabu
1 Replies

9. Programming

How system deamons consuming less memory

Dear all, When I write the daemon programs it is consuming high memory and processor time. How can I avoid this? But, the system daemons are not consuming more. How? Can any one explain how the system daemons are handling the memory consumption and processor time. Thanks,... (1 Reply)
Discussion started by: nagalenoj
1 Replies

10. Programming

Help -fwrite consuming lot of memory !!!

Hi , I am running a C/C++ program on a solaris 5.8 machine. This parituclar application has a module which saves data to a file. The module uses fwrite() function to save data. The fwrite function write about 500 MB of data to a file. The problem which I am facing is, the memory consumtion... (2 Replies)
Discussion started by: ajphaj
2 Replies
Login or Register to Ask a Question