Gerry Jensen:
> While it may be untrue that you *need* twice the physical memory size, I
> believe it's true that twice the physical memory size is about the limit
> of what you can effectively use if you need it.

It depends on what you do.

Operating system theory has a concept called "working set", which
is the group of virtual memory pages that are actually used at the
moment. In addition, there may other pages not in the working set
that are not used. If the size of the working set is much bigger
than physical memory, there will be heavy swapping and the system
will perform poorly. However, it does not matter if there are lots
of pages not in the working set, because they can be swapped out
and won't be swapped in (at least not in the near future).

For many people, the rule of "twice physical size" approximates
the size of the working set fairly well: half of the pages are
used at any one moment. For many others, it does not. It all
depends on what you do.

For example, if you have a getty running for six virtual
consoles, but you never log in more than once, the pages of the
other five gettys do not belong in the working set. They can be
swapped out.  In addition, if you have a sendmail daemon running,
but never send any mail, then it will also be swapped out. If
each getty uses 1 MB of non-shared memory, and sendmail uses 10
MB, you have now used 15 MB of swap. Assume you have 4 MB of
physical memory (and that whatever you do via the one log in uses
only 1 MB of memory). Your system is not swapping madly. It works
splendidly. No problems at all. Even if you have used about four
times as much swap as you have physical memory.

These numbers are completely wrong (getty does not use that much
memory), but they are good enough to show the point. The logic
is sound, I just invented numbers that are easy to follow.

My simple formula

        swap needed = total memory need - physical memory size
        
works much better than the "twice physical memory" one. It does
not mention working sets, mostly because then things get complicated;
but I guess I should explain about it in the SAG, where there is
more space.

-- 
Please read <http://www.iki.fi/liw/mail-to-lasu.html> before mailing me.
Please don't Cc: me when replying to my message on a mailing list.


Attachment: pgpiOpmRDVEI2.pgp
Description: PGP signature

Reply via email to