Re: Swap issue?



On 07/28/2008 09:08 PM, Alan Meyer wrote:
Shadow_7 wrote:
The rule of thumb (back in the 64MB days, was 2x RAM for swap. Although
these days you've got to be doing something pretty drastic to even use
swap much. When it's not available or maxed, it will start killing off
processes trying to stay alive.
...

A number of people have said this, but is it really true?
Why?

I don't believe that the kernel will kill one process in
order to give its memory to another. That would be kind
of crazy wouldn't it? How would it choose? What if it
killed a critical process in order to give memory to an
unimportant one?

<snip>

It is true. Consider a situation where you have 4GB of real+virtual
memory. You are running a process that has 2.5GB of memory allocated
and that process needs to fork/exec another program with a small memory
requirement. When you fork but before the exec you have two processes,
each with 2.5GB of memory allocated. You have now exceeded your memory
resources so if you are strict about memory allocations the fork should
not be allowed to happen. You now exec the small program and you drop
below your restrictions.

Linux, along with most UNIXes, allows memory overallocation. Allocation
is not the same as use and the killing of processes occurs when the use
of overallocated memory exceeds the total of ram + swap.

btw, part of the reason (back in the days of BSD-based Unix) for
swap = 2 x ram was that ram had to be backed by an equal amount of swap.
A program was loaded into both memory and swap and to allow for actual
virtual memory you increased the swap size.

Doug
.



Relevant Pages

  • Re: OT (slightly) swap limits
    ... influence your decision on how much swap was enough. ... processes due to lack of memory. ... I've run machines with 1Gig or more RAM with NO SWAP. ... Linux possible when before on Unix it wasn't? ...
    (Debian-User)
  • Re: How to set up a Linux machine that occupies the minimum memory footprint ?
    ... >> memory and hence causes the kernel to 'thrash' thus slowing down the ... 4GB physical RAM + 4GB swap area) the application will think that it can ... You've said in another message that your app is ...
    (comp.os.linux.setup)
  • Re: How to set up a Linux machine that occupies the minimum memory footprint ?
    ... >> memory and hence causes the kernel to 'thrash' thus slowing down the ... 4GB physical RAM + 4GB swap area) the application will think that it can ... You've said in another message that your app is ...
    (comp.os.linux.misc)
  • Re: fedora-list Digest, Vol 10, Issue 167
    ... Well, I have two 433 MHz Celerons and 288 MB RAM, and no performance ... > The memory usage is always around 400MB. ... I'd like to introduce you to the vmstat command. ... > I know that SWAP should be double the Physical RAM but I don't have ...
    (Fedora)
  • Re: FreeBSD data size tuning
    ... It seems there is a memory issue in 4.9 where they adapted 5.x things ... RAM and using 2500MB of swap on ide disk, ... With 1GB of RAM you should be able to run squid without any ...
    (freebsd-performance)