Re: Q: How much Swap space?

From: David Wright (david_c_wright_at_hotmail.com)
Date: 02/22/05


Date: Tue, 22 Feb 2005 09:43:56 +0100

Arthur Hagen wrote:

> David Wright <david_c_wright@hotmail.com> wrote:
>> Arthur Hagen wrote:
>>
>>> mjt <mjtobler@removethis_mail.ru> wrote:
>>>> if this is a home workstation, Linux may not use the swap.
>>>
>>> It always uses swap. How much depends on a lot of factors, but you
>>> should always see *some* swap use.
>>
>> total used free shared buffers cached
>> Mem: 775688 360040 415648 0 444 208904
>> -/+ buffers/cache: 150692 624996
>> Swap: 1052216 0 1052216
>
> Ok, let me take that back. On a typical modern computer that's been up
> for long enough and seen enough disk reads to fill up the memory with
> cache, you
> should always see *some* swap use. In the above case, you still have
> plenty of unused physical memory (which is a bad thing).
> With time, the Mem/cached figure should increase and the Mem/free figure
> decrease (which is a good thing), and once that gets low enough, a
> properly configured system should and will page out really old pages
> instead of
> discarding more frequently used disk cache. Unless you have an incredibly
> lean system, there will always be unused pages that can be swapped out.
> How much depends on the system and how it's used.
>
> Regards,

The only "bad" thing about not having used any swap, IMHO, is that I have
wasted a bit of money on unused RAM. Using the swap is slower than keeping
it in RAM. If there is no need to go to disk to store pages, then that is
more efficient than having to use the swap heavily.

I agree with part of your argument, that it should start swapping out the
least used pages to make way for more commonly used caches, but, if it can
can cache and keep everything in memory, then that is still more efficient
than using swap - it might be a little inefficient in memory cost terms;
I've spent slightly more money on memory than I may have needed.

OK, I agree, that machine hadn't been up long, less than 4 days.

My Gateway machine has been up since I upgraded it:

root@Defender:~ # uptime
 08:57:20 up 48 days, 16:08, 2 users, load average: 0.02, 0.03, 0.00
root@Defender:~ # free
             total used free shared buffers cached
Mem: 30108 25532 4576 0 744 9316
-/+ buffers/cache: 15472 14636
Swap: 59388 2852 56536

With only 32MB onboard, I would expect it to use a little bit of swap, but
2,8m isn't a lot, so that looks fairly healthy to me.

Dave



Relevant Pages

  • Re: Is Greenspun enough?
    ... Most OSes memory map executables directly from the file system so code doesn't pollute the file cache or swap space. ...
    (comp.lang.lisp)
  • Re: What can I check to fix system performance?
    ... it seems you have plenty of memory available: ... copies of files you have read of written lately, in a cache, in case ... processes per CPU, or 40 in all. ... Consider the disk structure. ...
    (comp.os.linux.setup)
  • Re: Is Greenspun enough?
    ... Most OSes memory map executables directly from the file ... >> system so code doesn't pollute the file cache or swap space. ... but executables have a twist. ...
    (comp.lang.lisp)
  • Re: Caching control
    ... |> | invalidate/unmap them in order to discard the data from memory. ... |> writing out to disk. ... | easy to discard as clean disk cache. ... stating that a specific amount of RAM can be used only for I/O ...
    (comp.os.linux.development.system)
  • Re: Scheduler: Process priority fed back to parent?
    ... > interactivity cache could estimate interactivity over a period of hours ... Then you don't even have to write it to the filesystem. ... For those of us with enough memory or a large variety of programs, ... That way the file is already in disk cache or on its way when the ...
    (Linux-Kernel)