[SGVLUG] used memory on a 4 GB system.

Claude Felizardo cafelizardo at gmail.com
Wed Nov 1 10:30:31 PST 2006


On 11/1/06, James Neff <jneff at tethyshealth.com> wrote:
> Greetings,
>
> I ran top and here are the results:
>
> top - 05:37:23 up 8 days,  1:44,  2 users,  load average: 0.00, 0.00, 0.00
> Tasks:  99 total,   1 running,  98 sleeping,   0 stopped,   0 zombie
> Cpu(s):  0.0% us,  0.1% sy,  0.0% ni, 99.9% id,  0.0% wa,  0.0% hi,  0.0% si
> Mem:   4039408k total,  4004660k used,    34748k free,    59444k buffers
> Swap:  2031608k total,      128k used,  2031480k free,  3713780k cached
>
>   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
>     1 root      16   0  7196  704  592 S    0  0.0   0:00.99 init
>     2 root      RT   0     0    0    0 S    0  0.0   0:00.11 migration/0
>     3 root      34  19     0    0    0 S    0  0.0   0:00.00 ksoftirqd/0
>     4 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/0
>     5 root      RT   0     0    0    0 S    0  0.0   0:00.15 migration/1
>     6 root      34  19     0    0    0 S    0  0.0   0:00.00 ksoftirqd/1
>     7 root      RT   0     0    0    0 S    0  0.0   0:00.00 watchdog/1
>     8 root      RT   0     0    0    0 S    0  0.0   0:00.03 migration/2
>
>
> This is a dual Opteron system (2 processors) with 2 GB of RAM for each
> processor.
>
> My question is, why does it say almost all of the memory is used?  Is
> this something I should be worried about or am I doing something wrong?
>
> uname -a
> Linux appserver2.tethyshealth.com 2.6.15-1.2054_FC5 #1 SMP Tue Mar 14
> 15:48:20 EST 2006 x86_64 x86_64 x86_64 GNU/Linux
>
> Thanks in advance,
> James

Short answer.  You might be okay.   Take a look at your swap usage.
You have 128k used which means you're not currently swapping.   Top
says you have 99 tasks but you're load avgs say zero so nothing is
currently active.

Long Answer.  A multitasking operating system relies on virtual memory
to provide enough memory to run multiple programs some of which may
require more memory then physical memory.  Each program uses memory
for execution code, data, stack and heap.  Not all of it is needed at
the same time, examples would be initialization code, a function only
used when a particular option is selected, etc.  Also, most programs
make use of shared libraries which means the code need only be loaded
into memory once and the kernel allocates memory for data for each
program/thread.   Total virtual used by a program is all code, data
and shared libraries plus memory pages swapped out.  For example,
looks like your init process (pid=1) is using 704k in core or resident
memory, 592k in shared memory and a total of 7196k of virtual memory.

Actually it's okay to have some swap in use as long as you aren't
constantly swapping memory in and out.  Valid example would be if you
have a large program that wakes up once an hour, does it's thing and
goes back to sleep.   But if you are running more than one big program
at the same time and it takes a while to wake it up then you might be
low on physical memory.  An example would be switching back and forth
between open office and your web browser.  If that takes a while then
you might need more physical memory.

Take a look at /proc/meminfo for some more stats or try running a
performance monitoring tool that plots memory usage vs time to see how
your system is doing throughout the day.  Also, take a look at the man
page for top and try sorting by memory usage.  I think you want to use
the O command then use the cap letters to change to sort order.

claude


More information about the SGVLUG mailing list