Click to See Complete Forum and Search --> : Memory Usage


thor420
12-31-2001, 10:52 AM
Heres a quick question about memory usage as reported by 'free'. I have 512MB ram. When I type free from console (no X-server) heres my output:

total used free shared buffers cached
Mem: 513004 414324 98680 0 29064 264892
-/+ buffers/cache: 120368 392636
Swap: 1052216 4424 1047792

That shows me that I am using 414MB, approximately, out of 513MB. That is sad. Here is my output of running processes:

PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
1 0.0 0.0 416 184 ? S Dec28 0:07 init
2 0.0 0.0 0 0 ? SW Dec28 0:05 [keventd]
3 0.0 0.0 0 0 ? SWN Dec28 0:00 [ksoftirqd_CPU0]
4 0.0 0.0 0 0 ? SW Dec28 0:01 [kswapd]
5 0.0 0.0 0 0 ? SW Dec28 0:00 [bdflush]
6 0.0 0.0 0 0 ? SW Dec28 0:03 [kupdated]
8 0.0 0.0 0 0 ? SW< Dec28 0:00 [mdrecoveryd]
72 0.0 0.1 1380 560 ? S Dec28 0:00 /sbin/rpc.portmap
78 0.0 0.1 1780 744 ? S Dec28 0:00 /usr/sbin/syslogd
81 0.0 0.0 1964 496 ? S Dec28 0:00 /usr/sbin/klogd -
83 0.0 0.1 1760 648 ? S Dec28 0:00 /usr/sbin/inetd
86 0.0 0.1 2624 868 ? S Dec28 0:00 /usr/sbin/sshd
90 0.0 0.1 1808 640 ? S Dec28 0:00 /usr/sbin/lpd
93 0.0 0.1 1356 584 ? S Dec28 0:00 /usr/sbin/crond -
95 0.0 0.1 1356 580 ? S Dec28 0:00 /usr/sbin/atd -b
109 0.0 0.5 40836 2952 ? S Dec28 0:05 /usr/sbin/httpd
111 0.0 0.0 1260 460 ? S Dec28 0:07 gpm -m /dev/mouse
123 0.0 0.3 5632 1764 ? S Dec28 0:12 /usr/sbin/cupsd
134 0.0 0.6 40892 3156 ? S Dec28 0:00 /usr/sbin/httpd
135 0.0 0.6 40892 3156 ? S Dec28 0:00 /usr/sbin/httpd
136 0.0 0.6 40892 3156 ? S Dec28 0:00 /usr/sbin/httpd
137 0.0 0.6 40892 3156 ? S Dec28 0:00 /usr/sbin/httpd
138 0.0 0.6 40892 3156 ? S Dec28 0:00 /usr/sbin/httpd
140 0.0 0.1 2360 868 ? S Dec28 0:00 proftpd (acceptin
187 0.0 0.1 2048 860 ? S Dec28 0:00 /usr/libexec/post
188 0.0 0.7 6472 4092 ? S Dec28 2:20 /usr/local/bin/sn
190 0.0 0.0 1220 448 tty2 S Dec28 0:00 /sbin/agetty 3840
191 0.0 0.0 1220 448 tty3 S Dec28 0:00 /sbin/agetty 3840
192 0.0 0.0 1220 448 tty4 S Dec28 0:00 /sbin/agetty 3840
193 0.0 0.0 1220 448 tty5 S Dec28 0:00 /sbin/agetty 3840
194 0.0 0.0 1220 448 tty6 S Dec28 0:00 /sbin/agetty 3840
196 0.0 0.1 2024 808 ? S Dec28 0:00 qmgr -l -t fifo -
263 0.0 0.6 40892 3160 ? S Dec28 0:00 /usr/sbin/httpd
875 0.0 0.6 40892 3160 ? S Dec29 0:00 /usr/sbin/httpd
26218 0.0 0.6 40892 3156 ? S Dec29 0:00 /usr/sbin/httpd
28222 0.0 0.2 2028 1244 tty1 S 05:09 0:00 -bash
29173 0.0 0.1 1972 800 ? S 07:11 0:00 pickup -l -t fifo
29439 0.0 0.1 2544 812 tty1 R 07:36 0:00 ps -aux


I guess I'm not understanding the whole deal with memory. Looking at the %MEM usage column, there is somewhere in the neighborhood of 5% of my total 513MB ram being used in processes, so wheres the other 95%? Any insights? Thanks

[ 31 December 2001: Message edited by: thor420 ]

mrBen
12-31-2001, 10:56 AM
I think you'll find that the free command shows things a little funnily. Something to do with the cached and buffered memory or something.

Derango
12-31-2001, 11:05 AM
Linux caches the files you recently accessed in your system RAM, its thinking being that if you accessed them once, you're probably going to have to use them again. For example, if you start up mozilla, then close it again, then start it up immediatly after you close it, it will load a good deal faster than the first time.

If a program needes the ram used to hold the cache, then it will save this data to the hard drive. It also serves to hold all hard drive writes to be done in one big group, which is faster than a lot of little writes.

speck
01-01-2002, 02:52 AM
From your example above, you have ~120MB used and ~392MB free. The real amount of used/free memory comes from the buffers/cache line of the free command.


total used free shared buffers cached
Mem: 513004 414324 98680 0 29064 264892
-/+ buffers/cache: 120368 392636
Swap:1052216 4424 1047792



Speck