boopage
By:
boopage

Memory Usage

May 2, 2013 2.8k views
Please anyone can help me to understand this? I want to find out why so many memory is used, how to optimize memory usage. is it the RES shows the memory usage? Also why I got multiple getty and postgres processes? that doesn't seems normal... Any help is appreciated. Thanks KiB Mem: 1019328 total, 950260 used, 69068 free, 21820 buffers KiB Swap: 524284 total, 0 used, 524284 free, 569288 cached PID to renice ^[^[^[^C PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 818 root 20 0 34620 1780 840 S 0.3 0.2 0:29.20 redis-server 1 root 20 0 24340 2180 1284 S 0.0 0.2 0:00.42 init 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:02.34 ksoftirqd/0 6 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 7 root rt 0 0 0 0 S 0.0 0.0 0:00.35 watchdog/0 8 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 cpuset 9 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper 10 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs 11 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns 12 root 20 0 0 0 0 S 0.0 0.0 0:00.16 sync_supers 13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default 14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd 15 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff 17 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd 18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md 20 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1 21 root 20 0 0 0 0 S 0.0 0.0 0:00.01 khungtaskd 22 root 20 0 0 0 0 S 0.0 0.0 0:00.09 kswapd0 23 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd 24 root 39 19 0 0 0 S 0.0 0.0 0:00.00 khugepaged 25 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark 26 root 20 0 0 0 0 S 0.0 0.0 0:00.00 ecryptfs-kthrea 27 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto 36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kthrotld 37 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_0 38 root 20 0 0 0 0 S 0.0 0.0 0:00.00 scsi_eh_1 40 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 binder 41 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:3 60 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 deferwq 61 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 charger_manager 62 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 devfreq_wq 210 root 20 0 0 0 0 S 0.0 0.0 0:05.12 jbd2/sda-8 212 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ext4-dio-unwrit 294 root 20 0 17232 640 452 S 0.0 0.1 0:00.05 upstart-udev-br 296 root 20 0 21600 1316 760 S 0.0 0.1 0:00.03 udevd 363 messageb 20 0 23924 1120 804 S 0.0 0.1 0:00.01 dbus-daemon 370 syslog 20 0 243m 1384 1064 S 0.0 0.1 0:00.22 rsyslogd 448 root 20 0 21596 780 220 S 0.0 0.1 0:00.00 udevd 449 root 20 0 21596 844 284 S 0.0 0.1 0:00.00 udevd 537 root 20 0 49972 2792 2200 S 0.0 0.3 0:00.05 sshd 540 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kpsmoused 587 root 20 0 15188 392 200 S 0.0 0.0 0:00.00 upstart-socket- 619 root 20 0 15784 948 784 S 0.0 0.1 0:00.00 getty 623 root 20 0 15784 952 784 S 0.0 0.1 0:00.00 getty 630 root 20 0 15784 952 784 S 0.0 0.1 0:00.00 getty 632 root 20 0 15784 948 784 S 0.0 0.1 0:00.00 getty 634 root 20 0 15784 952 784 S 0.0 0.1 0:00.00 getty 644 root 20 0 4332 680 544 S 0.0 0.1 0:00.00 acpid 645 root 20 0 19112 992 748 S 0.0 0.1 0:00.07 cron 646 daemon 20 0 16908 160 0 S 0.0 0.0 0:00.00 atd 723 postgres 20 0 127m 10m 8916 S 0.0 1.0 0:01.20 postgres 748 postgres 20 0 127m 2188 776 S 0.0 0.2 0:07.56 postgres 749 postgres 20 0 127m 1696 308 S 0.0 0.2 0:07.29 postgres 750 postgres 20 0 127m 3092 1044 S 0.0 0.3 0:02.07 postgres 751 postgres 20 0 98560 1808 320 S 0.0 0.2 0:02.51 postgres 774 root 20 0 215m 1900 1644 S 0.0 0.2 0:00.00 PassengerWatchd 777 root 20 0 549m 3504 2248 S 0.0 0.3 1:16.02 PassengerHelper 779 root 20 0 109m 9964 2420 S 0.0 1.0 0:00.11 ruby 782 nobody 20 0 165m 4480 3460 S 0.0 0.4 0:00.15 PassengerLoggin 814 root 20 0 37428 1040 220 S 0.0 0.1 0:00.00 nginx
2 Answers
The first I'd suggest to google for "understanding top command output".
P.S. No way I meant "let me google for you" :)
RES -- Resident size (kb)
The non-swapped physical memory a task has used.
RES = CODE + DATA.

VIRT -- Virtual Image (kb)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out.
VIRT = SWAP + RES.

So the resident memory usage is the one you want to pay more attention to but with databases don't forget they also have a lot of internal caching even if you don't tune them as they will like to cache various requests, indexes, and have other temporary tables that they use to return queries faster. Often without specifying specific limits they can begin to use most of the available system memory since if it is completely unallocated why not use it to perform a function.
Have another answer? Share your knowledge.