On Mon, Jan 17, 2011 at 4:23 PM, Grant <emailgr...@gmail.com> wrote:
>> I think the idea is never use swap if possible, but in a case where
>> you don't have swap space or run out of swap space I think it's still
>> possible to lose data.
>
> Isn't swap just an extension of system memory?  Isn't adding 4GB of
> memory just as effective at preventing out-of-memory as dedicating 4GB
> of HD space to swap?  I can understand enabling swap on a laptop or
> other system with constrained memory capacity, but doesn't it make
> sense to disable swap and add memory on a 24GB server?
>
> Is swap basically a way to save money on RAM?
>
> - Grant
>
>

OK, please keep in mind that I'm not a programmer or a sys admin so
take all of this with less than a grain of salt.

First, leaving out the hibernation issue that uses swap as
non-volatile memory, even then no, I don't think it's exactly the
same.

The kernel knows when memory is overfull & swap is coming into play so
it knows to change how it handles what's it allows to be done. You
always have the potential that some program starts filling memory with
data to be written to disk, but the kernel cannot flush that data out
to disk as fast as the program fills up memory, so memory fills
completely and the system starts swapping. At that point the kernel
can interrupt the program, start cleaning things up, and when memory
is back to some portion used and some portion free then it can let
programs take over again.

If you have no swap and completely run out of memory then there's some
potential that if the kernel needs memory of its own to get some job
done it may have to write over the top of some program's data and at
that point the data is lost.

I do agree that 4GB DRAM is better (most of the time) vs 4GB of swap.
However I have 2.5TB of disk space in my home server. I see no real
problem handing over 12GB (.5%?) of disk space to duplicate memory
size & have a more graceful slowdown at the limit of memory usage.

Thanks just me though.

Cheers,
Mark

Reply via email to