summaryrefslogtreecommitdiff
path: root/sag-0.6.1-www/Invisible/sag-0.6/node64.html
blob: e5bf5af823e4d168170b75b47a3e3a2877b3cdf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!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>Allocating swap space</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">
</HEAD>
<BODY LANG="EN" >
 <A NAME="tex2html1118" HREF="node65.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html1116" HREF="node59.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html1110" HREF="node63.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html1120" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html1121" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1119" HREF="node65.html">The buffer cache</A>
<B>Up:</B> <A NAME="tex2html1117" HREF="node59.html">Memory Management</A>
<B> Previous:</B> <A NAME="tex2html1111" HREF="node63.html">Sharing swap spaces with </A>
<BR> <P>
<H1><A NAME="SECTION00650000000000000000">Allocating swap space</A></H1>
 <A NAME="secswapalloc">&#160;</A>
<P>
	Some people will tell you that you should allocate twice as much
	swap space as you have physical memory, but this is a bogus rule.
	Here's how to do it properly:
<P>
    <OL>
<LI>
<P>
	Estimate your total memory needs.  This is the largest amount of
	memory you'll probably need at a time, that is the sum of the
	memory requirements of all the programs you want to run at the
	same time.  This can be done by running at the same time all the
	programs you are likely to ever be running at the same time.
<P>
	For instance, if you want to run X, you should allocate
	about 8 MB for it, gcc wants several megabytes (some
	files need an unusually large amount, up to tens of
	megabytes, but usually about four should do), and so on.
	The kernel will use about a megabyte by itself, and the
	usual shells and other small utilities perhaps a few
	hundred kilobytes (say a megabyte together).  There is
	no need to try to be exact, rough estimates are fine,
	but you might want to be on the pessimistic side.
<P>
	Remember that if there are going to be several people
	using the system at the same time, they are all going
	to consume memory.  However, if two people run the same
	program at the same time, the total memory consumption
	is usually not double, since code pages and shared
	libraries exist only once.
<P>
	The <tt>free</tt><A NAME="1924">&#160;</A> and <tt>ps</tt><A NAME="1926">&#160;</A> commands are useful for
	estimating the memory needs.
<LI>
<P>
	Add some security to the estimate in step 1.  This is because
	estimates of program sizes will probably be wrong, because
	you'll probably forget some programs you want to run, and to
	make certain that you have some extra space just in case.  A
	couple of megabytes should be fine.  (It is better to allocate
	too much than too little swap space, but there's no need to
	over-do it and allocate the whole disk, since unused swap space
	is wasted space; see later about adding more swap.)  Also,
	since it is nicer to deal with even numbers, you can round the
	value up to the next full megabyte.
<LI>
<P>
	Based on the computations above, you know how much memory
	you'll be needing in total.  So, in order to allocate
	swap space, you just need to subtract the size of your
	physical memory from the total memory needed, and you
	know how much swap space you need.  (On some versions
	of UNIX, you need to allocate space for an image of the
	physical memory as well, so the amount computed in step
	2 is what you need and you shouldn't do the subtraction.)
<LI>
<P>
	If your calculated swap space is very much larger than your
	physical memory (more than a couple times larger), you should
	probably invest in more physical memory, otherwise performance
	will be too low.
<P>
    </OL>
<P>
	It's a good idea to have at least some swap space, even if
	your calculations indicate that you need none. Linux uses
	swap space somewhat aggressively, so that as much physical
	memory as possible can be kept free. Linux will swap out
	memory pages that have not been used, even if the memory
	is not yet needed for anything. This avoids waiting for
	swapping when it is needed--the swapping can be done
	earlier, when the disk is otherwise idle.
<P>
	Swap space can be divided among several disks. This
	can sometimes improve performance, depending on the
	relative speeds of the disks and the access patterns
	of the disks. You might want to experiment with a few
	schemes, but be aware that doing the experiments
	properly is quite difficult. You should not believe
	claims that any one scheme is superior to any other,
	since it won't always be true.
<P>
<HR><A NAME="tex2html1118" HREF="node65.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html1116" HREF="node59.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html1110" HREF="node63.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html1120" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html1121" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME="tex2html1119" HREF="node65.html">The buffer cache</A>
<B>Up:</B> <A NAME="tex2html1117" HREF="node59.html">Memory Management</A>
<B> Previous:</B> <A NAME="tex2html1111" HREF="node63.html">Sharing swap spaces with </A>
<P><ADDRESS>
<I>Lars Wirzenius <BR>
Sat Nov 15 02:32:11 EET 1997</I>
</ADDRESS>
</BODY>
</HTML>