When I check free in one of Prod server it showing 70% of memory is being used:

             total       used       free     shared    buffers     cached
Mem:     164923172  141171860   23751312          0    4555616   20648048
-/+ buffers/cache:  115968196   48954976
Swap:      8388600          0    8388600

But I didn’t find what process is using the memory, I tried the top command and it is showing process using memory only 1.1 and 5.4 %

How can I find which process is using the memory?

Below are the top command results:

15085 couchbas  25   0 2784m 2.4g  40m S 183.7  1.5 299597:00 beam.smp
28248 tibco     18   0  124m 100m 3440 S 20.9  0.1   2721:45 tibemsd
15334 couchbas  15   0 9114m 8.6g 3288 S  9.0  5.4  12996:28 memcached
15335 couchbas  18   0  6024  600  468 S  2.0  0.0   1704:54 sigar_port
15319 couchbas  15   0  775m 2516  944 S  0.7  0.0 269:13.41 i386-linux-godu
12167 tibco     16   0 11284 1464  784 R  0.3  0.0   0:00.04 top
12701 root      15   0  451m 427m 2140 S  0.3  0.3  18:25.02 controller
13163 root      11  -5     0    0    0 S  0.3  0.0 289:58.58 vxglm_thread
  • 1
  • Thanks for quick response, Is there any way to check the what all opened files and which file is eating memeory. – user90640 Nov 7 '14 at 6:44
  • 1
    Try to sort the top output - when running, press Shift + m – Eenoku Nov 7 '14 at 7:37

This will show you top 10 process that using the most memory:

ps aux --sort=-%mem | awk 'NR<=10{print $0}'

using top: when you opened top press m will short process based on memory usage.

But this will not solve your problem, in Linux everything is either file or process. so the files you opened will eating the memory too. so this will not help.

lsof will give you all opened files with the size of the file or the file offset in bytes.

  • 3
    You can use head instead of this awk script - it gives the same output and you save yourself writing many strange characters. – styrofoam fly Jun 23 '17 at 13:33

Your ram isn't actually used. Linux just caches the stuff on your disk by default, and puts what it caches in the "used" section of ram.

If you load applications that actually use that RAM, it will be their for use.

See http://www.linuxatemyram.com/


You can pipe ps and sort to get the process using the most memory. It will also allow you specify other process details you wish to see with it:

ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -n -r | less

PS: The above assumes that your memory column is first "sort -k 1 -n -r"


You can use command slabtop to view what slab objects are used by kernel.
Also you can check output of /proc/meminfo

Look for these 2 lines in the output

Slab:              68136 kB
SReclaimable:      21208 kB 

Above example shows 68MB of slab cache being used by kernel and 21MB can be reclaimed. To reclaim you can use technique described here https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html-single/Performance_Tuning_Guide/#s-memory-tunables

echo 2 > /proc/sys/vm/drop_caches  

For an interactive analysis, you can use htop, then hit function key F6 to choose the sort-order, e.g. PERCENT_CPU (memory usage in percents), M_RESIDENT (resident memory size, the real memory that is used), M_SIZE (virtual memory size) or M_SHARE (size of shared memory). The first two are the relevant numbers.

The green lines are threads. Hit (upper case) K and H to hide them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.