Linked by Thom Holwerda on Wed 28th Feb 2007 19:29 UTC
Windows Jeff Atwood explains why Vista uses so much memory. "You have to stop thinking of system memory as a resource and start thinking of it as a a cache. Just like the level 1 and level 2 cache on your CPU, system memory is yet another type of high-speed cache that sits between your computer and the disk drive. And the most important rule of cache design is that empty cache memory is wasted cache memory. Empty cache isn't doing you any good. It's expensive, high-speed memory sucking down power for zero benefit. The primary mission in the life of every cache is to populate itself as quickly as possible with the data that's most likely to be needed - and to consistently deliver a high 'hit rate' of needed data retrieved from the cache."
Thread beginning with comment 217335
To read all comments associated with this story, please click here.
I don't get it.
by Buck on Wed 28th Feb 2007 19:57 UTC
Buck
Member since:
2005-06-29

Soo... suppose I have 16Gb of memory. Will Vista eat all of it (just for itself)? If yes, why is it good, I believe there's a natural limit on what to fill that cache with!

Edited 2007-02-28 19:58

RE: I don't get it.
by ma_d on Wed 28th Feb 2007 20:15 in reply to "I don't get it."
ma_d Member since:
2005-06-29

Because the cache is thrown away instantly when you need it for a process. It's as cheap to give a process cache memory as it is to give it free and unused memory (applications always expect garbage in newly allocated memory).

Cache is free, really. It means a small amount of CPU use to track the cache and a small amount of memory (which would shrink as you have less cache) and you gain faster disk accesses. It is win win, and I've never heard of a limit to its usefulness (beyond having more memory than disk space, but that's very unlikely).

This is part of why Unix systems improve their performance the longer they've been running.

I was, however, under the impression that XP already did this but didn't report on the cache use.

Reply Parent Bookmark Score: 3

RE[2]: I don't get it.
by msundman on Wed 28th Feb 2007 20:36 in reply to "RE: I don't get it."
msundman Member since:
2005-07-06

> Because the cache is thrown away instantly when you need
> it for a process.

I don't know about Vista, but I've seen linux start swapping instead of throwing away part of the 500+ MB it was using as cache. I tried adjusting swappiness and FS cache aggressiveness, but I couldn't make linux not lock up for short whiles (annoying e.g. when listening to music). In fact, I got so annoyed with these anti-desktop-oriented VMM algorithms (or whatever, I'm not a linux kernel expert) that I now have 3 GiB of RAM and no swap at all. Although there are still short lock-ups when some program suddenly starts using a lot of memory, they are at least an order of magnitude shorter than before.

Reply Parent Bookmark Score: 5

RE[2]: I don't get it.
by butters on Thu 1st Mar 2007 02:09 in reply to "RE: I don't get it."
butters Member since:
2005-07-08

Cache is free, really. [...] I've never heard of a limit to its usefulness

Until recently, you were 100% correct. But now we have ReadyBoost, a disk cache in flash memory, and this perilously close to destroying our theory that caching is always good.

Disks are moderately fast for sequential access and horrendously slow for random access. Modern DRAM is a couple orders of magnitude faster than a disk in sequential access and doesn't get much slower in random access, blowing the disk away by several orders of magnitude. The more you disk storage you can cache in DRAM, the better. Win-win, just as you said.

Flash memory, on the other hand, is not that much faster than a disk at sequential access. With a high-end disk, or an array of disks, it might actually be slower than the disk! So implementing a disk cache in flash memory is tricky. On some systems, you'll want to bypass the cache and go straight to disk if the request is sequential enough. On others, you don't get a significant performance improvement by reading sequential data from the cache. But for random access, the flash cache still blows the disk away. So you want to try to keep pages that are likely to be read randomly in the cache and evict pages that have been read sequentially to make room for pages that tend to be read more randomly.

Caching works under the assumption that higher-capacity devices will always be slower than smaller high-performance devices. But flash is so slow for its capacity, and disks are remarkably quick for their capacity at sequential reads, that it becomes a problem. There's just not enough of a performance delta between flash memory and disks in many situations.

Reply Parent Bookmark Score: 3

RE: I don't get it.
by martinus on Wed 28th Feb 2007 20:16 in reply to "I don't get it."
martinus Member since:
2005-07-06

suppose you have 16Gb of memory and your apps only need 1Gb, then any intelligent operating system would use the rest of 15Gb as a cache, and make it available to your applications when really needed.

Reply Parent Bookmark Score: 1

RE[2]: I don't get it.
by A.H. on Wed 28th Feb 2007 21:31 in reply to "I don't get it."
A.H. Member since:
2005-11-11

It will load up your entire hard drive into RAM. Twice if necessary.

Reply Parent Bookmark Score: 3