# Is my swap disabled?

## Tim77

I think my swap space isn't working properly. I started several programs and looked at the top-output:

```
top - 09:08:32 up 37 min,  1 user,  load average: 4.39, 2.95, 1.47

Tasks: 120 total,   2 running, 117 sleeping,   0 stopped,   1 zombie

Cpu(s): 72.1% us, 22.6% sy,  0.0% ni,  0.0% id,  0.3% wa,  3.3% hi,  1.7% si

Mem:    515716k total,   512812k used,     2904k free,    70532k buffers

Swap:  1052216k total,        0k used,  1052216k free,   207320k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

 4999 root      24   0  5132 4176 1372 R 24.1  0.8   0:35.41 bzip2

 3475 root      15   0  117m  48m  88m S 17.8  9.6   2:45.84 X

 5000 root      15   0  4068  860 3700 S 14.5  0.2   0:21.56 tar

 4867 tim       15   0  142m  45m  20m S 11.9  9.1   0:29.62 xine

    7 root      16   0     0    0    0 S  4.6  0.0   0:08.40 pdflush

 4038 tim       15   0  226m  41m  53m S  3.6  8.2   0:16.17 java

 3579 tim       15   0 15592 8492  13m S  3.3  1.6   0:24.01 xfce4-panel

 3581 tim       15   0 34324  20m  29m S  3.3  4.0   0:09.45 konsole

 4067 tim       15   0  226m  41m  53m S  3.3  8.2   0:14.53 java

 4868 tim       15   0  142m  45m  20m S  3.3  9.1   0:06.99 xine

 4866 tim       15   0  142m  45m  20m S  2.3  9.1   0:05.93 xine

 4864 tim       15   0  142m  45m  20m S  2.0  9.1   0:07.30 xine

 4858 tim       15   0  142m  45m  20m S  1.3  9.1   0:04.36 xine

 3986 tim       15   0  103m  33m  72m S  1.0  6.6   0:06.37 soffice.bin

 4875 tim       15   0  142m  45m  20m S  1.0  9.1   0:01.03 xine

    3 root       5 -10     0    0    0 S  0.3  0.0   0:01.01 events/0

 3835 tim       15   0 53712  30m  33m S  0.3  6.1   0:17.38 MozillaFirebird

 3842 tim       15   0 53712  30m  33m S  0.3  6.1   0:06.15 MozillaFirebird

 4037 tim       15   0 35748  16m  26m S  0.3  3.2   0:04.78 abiword-2.0

 4860 tim       15   0  142m  45m  20m S  0.3  9.1   0:00.49 xine

 5005 tim       16   0  1892  988 1728 R  0.3  0.2   0:00.05 top

    1 root      16   0  1324  500 1288 S  0.0  0.1   0:04.85 init

    2 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0

    4 root       5 -10     0    0    0 S  0.0  0.0   0:00.16 kblockd/0

    5 root      15   0     0    0    0 S  0.0  0.0   0:00.20 kapmd

    6 root      25   0     0    0    0 S  0.0  0.0   0:00.00 pdflush

    8 root      15   0     0    0    0 S  0.0  0.0   0:01.85 kswapd0
```

What is a zombie process? Which one is it? How do I get rid of it?

I think kswapd is a kernel swapping daemon. Am I right? If it's active, why don't I use no single bit of swap? I have started many big processes (OOffice, eclipse, MozillaFirebird, Evolution, Xine, abiword,...). If I remember correctly, I never saw my machine use swap   :Crying or Very sad:  Is this normal for "only" 512 MB Ram?

----------

## wyrickre

Look into using vmstat to view your memory usage.

As for zombie processes... a zombie process is a process that has ended but its parent has not yet waited on it (checked it's status).  In other words, it's parent hasn't yet realized that it has exited.

Read this or this for other explanations.  Though I must admit that this definition is my favorite.

----------

## Cosmin

Try swapon /dev/your_swap_partition.

Now, regarding zombie processes: when a program forks, one of them is the parent, the other is child. Normally, when the parent exits, it would send some sort of message to the child to tell it to exit. This doesn't always happen and isn't necessary a 'bad' thing. Zombies can appear when a thread is blocked and the process received a kill signal. If the process can't stop the thread and exit gracefully, you get a zombie.

Of course, my explanation here can be easily attacked.

----------

## Tim77

```
tim [~] $ vmstat

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----

 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa

 0  0      0   3520   8376 375812    0    0   942    10 3794   679 22 33 35 10
```

```
swapon /dev/hda6
```

Then it says that this ressource is busy (I don't know if this translation is correct. My term shows the german output). Still no swap usage...   :Sad: 

----------

## jana

This may be a silly question, but once you've killed that zombie process are you still using all of your ram?  I've got 512MB, too, and it takes running a LOT of programs before I start using swap.  Have you tried running 2438384 big programs and looked at your swap usage?

 - j

----------

## Tim77

So in 99.999% you don't need swap space (on a desktop machine with 512 MB Ram)?

How do I find out, which one is the zombie? I don't see any status-Z.

----------

## Cosmin

If your swap partition is 'busy', as reported by swapon, than that's it! You are using it! If it is 0 used, this means you don't need it! I see your proc is 4% used, so why should you use swap? Try to compile something big, you could unpack something from /usr/portage/distfiles in your home directory and compile it. This should make a difference...

----------

## jana

Yup, or at least that's been my experience.  Cosmin's idea is a good one...  compile something big, watch your memory get used up, and you should overflow into swap.  It won't help you fix anything, but if you're interested in keeping tabs on what your machine is doing, emerge gkrellm2.  You can display memory and swap krells, and when you click on them it can tell you how much you've got vs. how much you're using.

 - j

----------

