View Single Post
Posts: 253 | Thanked: 1,007 times | Joined on May 2010 @ Near Munich
#36
For your first question (honest questions are never stupid!):

Ram is built into devices for a reason, it has advantages over normal storage:
(Near) infinite reads and writes
Very fast reads and writes (orders of magnitude!)
But it looses its data when turned of.
So you use it to
  1. store data which will be written to disk
  2. data you only need to operate your running programs
  3. data which you read so often you want to save time by storing it in RAM, where reads are much faster.

If you add swap, you tell the system to handle a bit of normal storage like ram. Obviously its fully useless for 1 and 3, because your swap is already a slow as the disk. This leaves us with usage 2. But your software expects RAM to be fast, so it changes its contents all the time. Every time something changes in your software your RAM content changes. And many things change, when, for example, your scroll a webpage.

The operation system now tries to work around this.
See that tab he has in background for 5 minutes? We can probably move it to swap, it won't change soon and the user can wait a few sec, when he activates it again. If he does, we move it to RAM and seek another inactive tab to move to swap.

This works somewhat well, till you are at a point where the fast changing contents alone use all your RAM. As modern browsers expect much RAM (and need it to render many of todays huge websites) They have big areas of RAM where contents change often.

Now these will spread to swap and things get really slow. Your firefox expects that RAM read and write to be done in 1 ms, but now its writing to swap on disk and takes 1s instead. It will still work, but the user will grow a beard till the webpage is rendered.
 

The Following 9 Users Say Thank You to Macros For This Useful Post: