190 lines
4.0 KiB
HTML
190 lines
4.0 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>What is virtual memory?</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Linux System Administrators Guide"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Memory Management"
|
|
HREF="memory-management.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Memory Management"
|
|
HREF="memory-management.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Creating a swap space"
|
|
HREF="swap-space.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Linux System Administrators Guide: </TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="memory-management.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 6. Memory Management</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="swap-space.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="VM-INTRO"
|
|
></A
|
|
>6.1. What is virtual memory?</H1
|
|
><P
|
|
>Linux supports <I
|
|
CLASS="GLOSSTERM"
|
|
>virtual memory</I
|
|
>, that
|
|
is, using a disk as an extension of RAM so that the effective
|
|
size of usable memory grows correspondingly. The kernel will
|
|
write the contents of a currently unused block of memory to the
|
|
hard disk so that the memory can be used for another purpose.
|
|
When the original contents are needed again, they are read back
|
|
into memory. This is all made completely transparent to the
|
|
user; programs running under Linux only see the larger amount of
|
|
memory available and don't notice that parts of them reside on
|
|
the disk from time to time. Of course, reading and writing the
|
|
hard disk is slower (on the order of a thousand times slower)
|
|
than using real memory, so the programs don't run as fast.
|
|
The part of the hard disk that is used as virtual memory is
|
|
called the <I
|
|
CLASS="GLOSSTERM"
|
|
>swap space</I
|
|
>.</P
|
|
><P
|
|
>Linux can use either a normal file in the filesystem or a
|
|
separate partition for swap space. A swap partition is
|
|
faster, but it is easier to change the size of a swap file
|
|
(there's no need to repartition the whole hard disk, and
|
|
possibly install everything from scratch). When you know how
|
|
much swap space you need, you should go for a swap partition,
|
|
but if you are uncertain, you can use a swap file first, use
|
|
the system for a while so that you can get a feel for how much
|
|
swap you need, and then make a swap partition when you're
|
|
confident about its size.</P
|
|
><P
|
|
>You should also know that Linux allows one to use several swap
|
|
partitions and/or swap files at the same time. This means
|
|
that if you only occasionally need an unusual amount of swap space,
|
|
you can set up an extra swap file at such times, instead of
|
|
keeping the whole amount allocated all the time.</P
|
|
><P
|
|
>A note on operating system terminology: computer science
|
|
usually distinguishes between swapping (writing the whole process
|
|
out to swap space) and paging (writing only fixed size parts,
|
|
usually a few kilobytes, at a time). Paging is usually more
|
|
efficient, and that's what Linux does, but traditional Linux
|
|
terminology talks about swapping anyway.
|
|
</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="memory-management.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="swap-space.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Memory Management</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="memory-management.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Creating a swap space</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |