I m trying to analyse the memory (RAM) used by the Linux system.
The broad classification of memory usage is split into
a) User Space memory
b) Kernel Space memory
I have been using tools ( TOP , slabtop and free)
Let me brief how i calculated User Space memory Consumption
top (Shit + m) sorts based on memory consumed .
Shown below is the sorted list based on memory Consumption
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2309 root 20 0 189m 35m 6324 S 0.0 7.1 5:42.54 java
794 root 20 0 33900 25m 3204 R 87.6 5.0 0:02.64 cc1
1542 mysql 20 0 126m 18m 5184 S 0.0 3.8 0:05.85 mysqld
795 root 20 0 5508 3184 784 S 0.0 0.6 0:00.00 as
1875 root 20 0 13268 2800 1384 S 0.0 0.6 0:00.11 apache2
4837 root 20 0 8312 2688 2216 S 0.0 0.5 0:35.95 sshd
27080 root 20 0 8312 2688 2216 R 0.0 0.5 0:00.35 sshd
1881 www-data 20 0 229m 2600 1056 S 0.0 0.5 0:00.00 apache2
1877 www-data 20 0 229m 2596 1052 S 0.0 0.5 0:00.00 apache2
1876 www-data 20 0 13040 1964 556 S 0.0 0.4 0:00.00 apache2
<snip>
I m adding up all the memory under (RES) which is Resident memory in the RAM , which leads us to the calculation of
how much (RAM) the user space has consumed .
slabtop -s c , shows the total slabs used etc
Active / Total Objects (% used) : 146013 / 152910 (95.5%)
Active / Total Slabs (% used) : 5714 / 5715 (100.0%)
Active / Total Caches (% used) : 84 / 142 (59.2%)
Active / Total Size (% used) : 20821.62K / 21780.46K (95.6%)
Minimum / Average / Maximum Object : 0.01K / 0.14K / 4096.00K
12736 12078 94% 0.48K 1592 8 6368K ext3_inode_cache
80601 79231 98% 0.05K 1203 67 4812K buffer_head
10686 10176 95% 0.28K 822 13 3288K radix_tree_node
1342 1336 99% 2.00K 671 2 2684K size-2048
<snip>
# free
total used free shared buffers cached
Mem: 508612 490768 17844 0 30664 367372
-/+ buffers/cache: 92732 415880
Swap: 1485972 64 1485908
free which is supposed to show the total memory consumption
Using these tools i m able to account roughly around
100 MB of user space data
20 MB of kernel space (slab allocs)
The total memory is around 512MB out of which i m able to account only for 120MB of memory .
Can someone shed some light this ?
Thanks,
Anand