Re: Swap issue?
- From: Douglas O'Neal <oneal@xxxxxxxxxxxx>
- Date: Tue, 29 Jul 2008 08:20:25 -0400
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
.
- References:
- Swap issue?
- From: howa
- Re: Swap issue?
- From: Shadow_7
- Re: Swap issue?
- From: Alan Meyer
- Swap issue?
- Prev by Date: Re: mysqld wont start...
- Next by Date: Re: mysqld wont start...
- Previous by thread: Re: Swap issue?
- Next by thread: Re: Swap issue?
- Index(es):
Relevant Pages
|