Memory, swap, and limits

Rick Stevens ricks at nerd.com
Wed Jun 18 16:50:37 UTC 2008


Beartooth Sciurivore wrote:
> On Wed, 18 Jun 2008 08:58:47 -0500, Mikkel L. Ellertson wrote:
> 
>> Beartooth Sciurivore wrote:
> 	[...]
>>> 	Otoh, I've never gotten anywhere near filling up a hard drive,
>>> except once when I had a testbed machine triple booting three different
>>> distros. So why can't I at least increase the swap space?
>>>
>> I believe there is a limit to the size of a swap partition. I don't
>> remember what it is. But you can create more then one swap partition.
>> The system will use them all. You also have the option of adding a swap
>> file after install. Try this, and see if it helps. But remember, when
>> you start doing a lot of swapping, the system is going to slow way down.
> 
> 	OK; but then there's something else I don't know, or don't 
> understand. Does a Fedora machine do any swapping while it has memory 
> left? I didn't think I had (or needed) any control at all over swapping, 
> beyond choosing how much space to afford it.

The portion of a process' code that is to be executed must be in RAM,
along with any data structures it may need (unless they're the
un-mmap(2)d parts of files).  If there is inadequate contiguous space
in RAM, idle processes will be swapped out to the swap space until there
is sufficient contiguous RAM to load the required code and data
structures for the process in question.

If your RAM is heavily fragmented or heavily used, the system may find
it difficult to locate adequate contiguous RAM and spend a lot of time
swapping things to disk and back as tasks compete for the free RAM.

The free(1) program can show a 10,000-foot view of your memory.  The
output of vmstat(8) is quite useful.  I use "vmstat 5" to get 5-second
snapshots of what is going on.  The "si" (swap in) and "so" (swap out)
columns tell you how many swap operations are occuring during the
sample.  If you see a lot, you're either running a lot of programs or
your memory is fragged.  Also pay attention to the "cs" (context
switches) column.  That tells you how often during the sample your
machine gave time slices to processes on the run queue.  A high number
indicates a lot of programs competing for space.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer                       rps2 at nerd.com -
- Hosting Consulting, Inc.                                           -
-                                                                    -
-                   To err is human, to moo bovine.                  -
----------------------------------------------------------------------




More information about the fedora-list mailing list