RAM disks are, as mentioned in xerces's WU, an area of RAM that is mapped as a disk drive. Why would you do this?
Back in the good old days, there were computers that couldn't really access all of their memory in an efficient way - such as:
- The Atari 130XE had 128 KB of RAM, but the 6502 processor could only see 64 KB at a time. The other 64 KB was paged in and out of main memory.
- IBM PCs under DOS could only see 640 KB of RAM, despite having sometimes a few megabytes of RAM. (NB: Bill Gates never said "640 K should be enough for anybody").
So what to do with this RAM that couldn't easily be seen?
Many of these machines also only had floppy disk drives, with no hard disk. So much disk swapping was the norm, to say nothing of slow access speeds. With a RAM disk, you could copy over the things you want to use during your session, and they would then always be there until you turned the machine off. There were even memory expansion units for some machines that you could use as a RAM disk, and that had their own battery backup - so when you turned the computer off the RAM disk retained its data.
On modern machines, with hard disks, they are less useful as there is no need for swapping floppies around - and on top of this, modern machines can more efficiently use their entire memory for running programs. However there's still the advantage of RAM disks being fast, even faster than hard disks.
Some operating systems take the attitude that "free memory is wasted memory", and use any free memory for buffers and cache - again, to speed up access by keeping things in memory. They then release this memory as soon as it is needed. An example of this can be seen on the "free" command in Linux.
total used free shared buffers cached
Mem: 222992 210364 12628 0 42580 62836
-/+ buffers/cache: 104948 118044
This shows that we have used about 210 MB and have about 12.5 MB free. But we can also see that about 42.5 MB of this used memory is bufers and nearly 63 MB is disk cache. This is all space that could be re-allocated to programs if required - hence the line below, showing that we're really only using about 105 MB and have about 118 MB free.
How is this similar to a RAM disk? What we have here can be seen as a RAM disk that:
- Automatically caches the things you're using regularly.
- Grows and shrinks as required.
And hence is very useful!
As an aside, call points out that RAM disks do also exist in Linux, and says that they can be very useful too.