Wrong wrong wrong wrong wrong wrong. Did I mention wrong. Virtuallock generally should not be used by most applications, there is usually no reason to force the pages to be held in physical memory and not be swappable. It's the job of the memory subsystem to make these decisions, not each developer (otherwise, I promise you EVERY application would simply try to lock everything into memory).
Ack... now I'm really confused about this issue. First I hear that devs explicitly control the memory to get the best performance. Next I hear that the OS is making all the memory decisions, not the apps. Bottom line, what pushes an app to use swap space, the OS or the applications themselves? Do developers
force apps like Photoshop and Mozilla to use swap space, or is that the OS's job?
On another earlier point, someone made the comment about a swapfile sometimes being required and certain applications needing one. The issue is not that the application itself (per say) 'needs one', but rather the developer used certain API's (such as unnamed memory backed files) which are internally implemented via the swap file.
Ok, this is my understanding so far...
The memory manager will try to use RAM as much as possible and not swap out
UNLESS
1. The subsystem
wants to use the disk as memory to perform its operations.
2. Apps tell the OS that it
wants to use the disk as memory.
What I don't understand is why. Fundamentally, the disk is supposed to slowly access unwieldy amounts of hardly used
non-volatile information. Using the disk as memory defeats this purpose because
1. You're dealing with a manageable amount of data
2. You're quickly accessing and modifying data all the time
3. You're dealing with volatile information
The
ONLY time I see an app using the disk as memory is when a system is stressed with multiple memory-hogging apps. In other words, when 1 or more of the above conditions fail. But, how can a system be "stressed" if several memory-hogging apps combined take only 1/4 of the total system memory(1 GB)?
Feeling tired now. Sorry if it feels like I'm ranting.