eekee wrote:thewrongchristian wrote:Quite apart from anything else, it's nice to have swap on an SSD, and putting aside soooo much expensive FLASH just to accommodate bad programming seems ... expensive. The only reason you'd so much swap is to swap memory that is most likely leaked and therefore literally useless data.
I think some well-designed programs can't avoid heavy memory use, depending on what they need to do. However, I think most complex programs today allocate a lot of memory just to speed things up, whether in caches or something else. I think that includes automatic garbage collectors in the runtime of many languages from Emacs Lisp to .NET. On topic, Virtualizers and emulators certainly can't avoid heavy memory use for allocated RAM and the framebuffer if there is one. They may have reason to cache disk access. Non-raw disk image formats must require some memory. VMware, being a professional product which existed long before CPUs had virtualization support, might very well cache translated binaries.
You have three scenarios, when you're actively using this much swap:
- You have very heavy memory use, all still managed and referenced, and periodically accessed, but working set doesn't exceed RAM.
- You have very heavy memory use, all still managed and referenced, and periodically accessed, but working set does exceed RAM.
- You have very heavy memory leakage, and the swapped out memory is no longer referenced but is taking up space.
If you have the first, and memory is being cycled between RAM and swap, typically because you have very heavy VM images, and your working set doesn't exceed the amount of RAM you have, then your application isn't utilising memory very efficiently. It's caching stuff that isn't referenced, so what's the point?
If you have the second, and memory is being cycled between RAM and swap, typically because you have very heavy VM images, and your working set exceeds the amount of RAM you have, then you'll start thrashing and your only solution is to install more RAM, or shrink the required RAM (by reducing cache sizes or migrating VMs to another machine.)
If you have the third, then you're just wasting disk space with badly behaving applications, but active working set may not exceed the amount of RAM.
The idea of a cache is to keep data on a quicker, transient storage medium. In RAM, you cache stuff that is on disk. On disk, you cache stuff that lives remotely (such as an HTTP caching proxy.) If your RAM cache ends up in swap, your cache is oversized.