Doing nothing at all on fedora linux I have 200MB in swap with nothing running at all out of the box installation
Yes OK, and so what? This does not hurt. These are 200MB that you would not otherwise have available for your application. It's supposed to be that way.
Windows 8.1 doing nothing fresh startup has 960MB memory cached not sure if that means to the disk or what that is and 1125MB in use
Windows 8.1 is a tough one to discuss because Windows 8 (and 8.1) does a lot of obscure stuff, such as letting programs run on in a "kind of frozen" state when it told you that the program has terminated. That's presumably for shorter startup times or such, but it sure makes looking at numbers and judging them even more complicated.
When it says "cached", however, this means file buffer cache. There exist "optimizer software" written by unwitting programmers (or unscrupulous ones, that's also possible) who are sold to unwitting users to "optimize" their memory by freeing this memory. The idea sounds good (if you don't know how VM works), but it's all snake oil.
Freeing memory means no more and no less than the next time data which used to be in the cache must be reloaded from disk, which has millisecond latency and consumes extra power (very noticeable on a portable device). On the other hand, the RAM is plugged into the computer (and powered) anyway, whether you use it or not. There is absolutely no advantage in not using it.
The virtual memory manager makes sure that it kicks off stuff from the cache (or the ready list) first, rather than pages that are hot in your working set. Having 900+MB cached is absolutely not a bad thing, on the contrary.
VirtualLock. The problem is what you're doing is boneheaded and exposes a very serious lack of understanding about what the OS is doing
Windows even tries hard to prevent you from doing this kind of thing because it is so unwise to do it. You are only allowed to lock up to your "maximum working set size", which is 16MB without changing this tuneable parameter first (and that needs administrative privilegues). So even if you do lock your memory (naively), it won't have any effect since the call to VirtualLock will simply fail (and since nobody checks error codes, you'll probably not even notice).
Now you are going to say "Wait, what, maximum working set size???". Yes, it is exactly as you think, the actual set of pages that is -- formally -- resident is very small. Pages are moved in and out of your working set all the time, and the vast majority of your pages is not in it at any time. But that does not mean that these pages are being written to disk all the time. It means that they are a possible candidate, in case no less important page can be found to be purged when you ask for more commit.
It is a logical management thing, which allows the operating system to keep the computer operational and reactive, regardless of what applications you launch or what memory they consume. It is not "swapping to disk" all the time.
This is very similar to high/low priority threads. A low priority thread doesn't "not fully utilize" the CPU (people sometimes believe that!). A lower priority thread runs, well, with lower priority, compared to a higher priority one. But it still uses 100% of what is available, and you do not get better CPU usage by assigning a higher priority.
Edited by samoth, 21 July 2014 - 08:10 AM.