So many of the comments to the "How to Use RAM as Swap" article were along the line of "RAM should only be used as RAM. Since Swap was invented to compensate for not having enough RAM, it is sacreligious and Blasphemy to ever turn around and then use RAM as swap, even if there is enough total memory to do it." Well, to some extent, conditions have changed, so that now there are situations where there can be more than enough RAM, and it is entirely OK to use it as a ramdrive swap area. Besides, the rules for the kernel have developed assuming there will be swap, even though now we can have enough RAM without swap. It is because of the way the kernel has developed, because some of its operations are based on swap existing, that it is better to have some swap space.
I recently investigated the actual output of the free command and the cat /proc/meminfo command. I guess I had suspected something was amiss because I noticed that free and meminfo reported a lot of memory in caches when I knew I was taking up a lot of memory with the ramdisks, and the ramdisks were completely full of data.
With full ramdisks, apparently the ramdisk is still counted as cache. Even though there is no hope if reclaiming it, it shows up as cached in both meminfo and free. This way of presenting the information is worse than not presenting it, because it causes people to be misled into thinking there is something wrong with the kernel, that it goes into swap hell when there are still 500 Megs in caches that it should reclaim and use before swapping aggressively and just about stopping the system cold. But in this case it can't reclaim much of what is in "caches" because it is locked for use by the ramdisk or the application using it. It can't just evict pages that hold the virtual machines in VMWare. It certainly can't just evict pages that are in ramdisk.
It is interesting to me that there was so much emphasis on
_wasting RAM_. To me, swapping out perfectly good
applications so that there is more room for cache and buffers
is much more a waste of RAM than using a ramdisk for swap.
Using a ramdisk for swap (swapram) keeps the amount of
RAM consumed as caches and buffers down to a more
reasonable amount, and then, anything that is swapped
I was looking in the rhel-rg-en.pdf Reference Guide, and saw that they defined Swapcached in an interesting way, and then searched on the web for Swapcached, which yielded a bit more, but not a lot. So here are some definitions (which can't all be right):
SwapCached: Memory that once was swapped out, is swapped back in but
still also is in the swapfile (if memory is needed it
In some testing of this so far, it is very clear that if there is not enough total memory for what is running on the computer, something dire is going to happen. So, for the case where there is not enough total memory when swap is disabled, swap was necessary.
So one answer to "Is Swap Necessary?" is yes. For many conditions the answer is yes. It is not a case of "just join the enlightened and disable swap like the rest of us." I would submit that to be safe in disabling swap, RAM should be added to cover the loss of the swap space. Unless it is known that the amount of RAM is going to be adequate with swap shut off, swap should not be disabled.