📄 node64.html
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--Converted with LaTeX2HTML 96.1-h (September 30, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->
<HTML>
<HEAD>
<TITLE>分配对换空间</TITLE>
<META NAME="description" CONTENT="Allocating swap space">
<META NAME="keywords" CONTENT="sag">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<LINK REL=STYLESHEET HREF="sag.css" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/sag.css">
</HEAD>
<BODY LANG="EN" >
<A NAME="tex2html1098" HREF="node65.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node65.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="next_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/next_motif.gif"></A> <A NAME="tex2html1096" HREF="node59.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node59.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="up_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/up_motif.gif"></A> <A NAME="tex2html1090" HREF="node63.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node63.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/previous_motif.gif"></A> <A NAME="tex2html1100" HREF="node1.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/contents_motif.gif"></A> <A NAME="tex2html1101" HREF="node108.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node108.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="index_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1099" HREF="node65.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node65.html">The buffer cache</A>
<B>Up:</B> <A NAME="tex2html1097" HREF="node59.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node59.html">Memory Management</A>
<B> Previous:</B> <A NAME="tex2html1091" HREF="node63.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node63.html">Sharing swap spaces with </A>
<BR> <P>
<H1><A NAME="SECTION00650000000000000000">分配对换空间</A></H1>
<A NAME="secswapalloc"> </A>
<P>
也许有人告诉你,应该分配2倍于物理内存的对换空间,但这是个虚假的规律。下面说明如何正确:
<P>
<OL>
<LI>
<P>
估计你的全部内存需求。这是你可能需要的最大量,即你要同时运行的所有程序所需的内存要求的总和。
你可以同时运行你可能同时运行的所有程序试试。
<P>
例如,如果你想运行X,你得分配8MB给他,gcc要求数MB(有些文件偶尔可能需要很大量,数十MB,
但一般4MB差不多),等等。核心自己使用1MB,Shell和一些小工具可能需要几百KB(或说,总共1MB)。
不必太精确,粗略估计就行,但可以较悲观地考虑。
<P>
记得如果将有多人同时使用系统,他们将都消耗内存。如果2个人同时运行相同的程序,总内存消耗一般并非
加倍,因为代码页和共享库是单一的。
<P>
<tt>free</tt><A NAME="1923"> </A>和<tt>ps</tt><A NAME="1925"> </A>命令对估计内存需求很有用。
<LI>
<P>
第一步的估计加上一些安全量。因为对程序大小的估计很可能是错误的,因为你可能忘了一些要运行的程序,
并确定你有一些额外空间。应该有数MB。(分配太多对换空间比分配太少好,但不必过分,因为不使用的
对换空间是浪费;见后文:关于增加对换空间。)
Also,since it is nicer to deal with even numbers, you can round the value up to the next full megabyte.
<LI>
<P>
基于以上计算,你知道了你总共需要多少内存。减去你的实际物理内存,就是对换空间。
(有些版本的UNIX中,你还需要分配物理内存的映象空间,所以第二布中计算的你所需的空间就不能减)
<LI>
<P>
如果你计算的对换空间比你的实际物理内存大得多(大于好几倍以上),那么你也许需要更多的物理内存,
否则系统性能将太低。
<P>
</OL>
<P>
即使计算显示你无须对换空间,最好还是至少有一些。Linux有些侵略性地使用对换空间,这样保持一定
的空闲物理内存。即使内存还不为什么程序所需,Linux也会换出一些不用的内存页,这样在需要的时候
就可以避免因对换的等待--即对换可以在硬盘空闲的时候提早完成。
<P>
对换空间可以分在几个硬盘中,这有时可以提高性能,依赖于这些盘的相对速度和存取模式。
你可以尝试几中方案,但要知道正确地尝试是很困难的。
不要相信某种方案比其他方案好的断定,因为它不会总是对的。
<P>
<HR><A NAME="tex2html1098" HREF="node65.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node65.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="next_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/next_motif.gif"></A> <A NAME="tex2html1096" HREF="node59.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node59.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="up_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/up_motif.gif"></A> <A NAME="tex2html1090" HREF="node63.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node63.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/previous_motif.gif"></A> <A NAME="tex2html1100" HREF="node1.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/contents_motif.gif"></A> <A NAME="tex2html1101" HREF="node108.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node108.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="index_motif.gif" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1099" HREF="node65.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node65.html">The buffer cache</A>
<B>Up:</B> <A NAME="tex2html1097" HREF="node59.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node59.html">Memory Management</A>
<B> Previous:</B> <A NAME="tex2html1091" HREF="node63.html" tppabs="http://linux.ccpi.gov.cn/Linux/linuxadmin/node63.html">Sharing swap spaces with </A>
<P><ADDRESS>
<I>Lars Wirzenius <BR>
Sun Jun 29 13:31:22 EEST 1997</I>
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -