Re: [squid-users] SWAP constantly growing

From: Donovan Baarda <abo@dont-contact.us>
Date: Sat, 10 Aug 2002 00:19:37 +1000

On Fri, Aug 09, 2002 at 01:49:33AM -0400, Ron Vachiyer wrote:
>
> >> >What is the size of your cache_dir?
> >>
> >> This is my config:
> >>
> >> cache_dir diskd /cache1 13500 28 256 Q1=72 Q2=64
> >> cache_dir diskd /cache2 13500 28 256 Q1=72 Q2=64
> >> cache_dir diskd /cache3 12500 28 256 Q1=72 Q2=64
> >
> >You have enough RAM for your cache.
> >Try "man ps" to find out how to get the processes and the amount of memory
> >used by them.
>
> Hello,
>
> I don't really get much useful info from ps -axv as everything seems
> normal. What is strange is that if I do a swapoff and a swapon while squid
> is running, it clears the swap, and then slowly grows back to about half of
> what it was before (?). Are there any known memory leaks in Linux 2.4.18
> anyone?

need some figures... you have nearly 40G of cache_dir. How full is this
cache dir? Squid will use about 8M RAM per 1G disk, so you are looking at
above 320M RAM to avoid thrashing. This does not include cache_mem, which is
extra. You say swap "grows"... to what? How much swap do you have? Show us
your output from "free".

Linux will naturally move "dead code" into swap as it uses memory for disk
buffer space. This is memory used by librarys and programs that are actively
running, but not regularly accessed... ie infrequently accessed library
routines, initialisation code, whatever. This is normal. It is better to
have regularly accessed disk blocks buffered in memory than parts of running
processes that are rarely accessed.

Turning swap off simply forces the kernel to move the swapped out dead code
back into memory, reducing the amount of buffer space available. As soon as
you re-enable swap, the kernel will begin migrating the dead code back into
swap, increasing the disk buffer space as the disk is accessed. Running
anything that actively uses lots of memory and/or disk will quickly force
dead-code into swap as the kernel tries to juggle between maximising buffer
space and actively used process memory.

This is why swap is a good idea even if you have 1G RAM... it allows the
kernel to more effectively use that RAM by "freeing up" the memory wasted on
dead-code so it can be used for disk-buffering.

It is not unusual for my systems to use around 30~100M swap even when they
have heaps of memory. This depends on how much stuff you are running.

-- 
----------------------------------------------------------------------
ABO: finger abo@minkirri.apana.org.au for more info, including pgp key
----------------------------------------------------------------------
Received on Fri Aug 09 2002 - 08:19:41 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:09:34 MST