Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

A process can use upto 4 GB of virtual memory (including user and kernel) but when it's not using virtual memory does it have the kernel and user memory in ram?

share|improve this question

1 Answer 1

Using virtual memory is not optional, an application cannot avoid it. Assuming we're talking about x86 protected memory which is what most current operating systems such as Linux, OS X and Windows use on x86.

Basically, each process sees a 4 GB virtual address space (VAS). The OS, in conjunction with the hardware, sets up so-called page descriptor tables (PDT) that describe how that VAS is mapped, with page granularity (typically 4 KB). A page may be mapped to physical memory, it might be mapped to a file (meaning that when the process tries to read from that part of the VAS, it will trap into the OS which will then read the page from the file on disk and place it into memory), or it might not be mapped at all in which case trying to access that part of the VAS will cause the process to crash. And, as an aside, while the kernel memory is mapped into the process, the process cannot access it directly and will crash if it attempts to do so.

And, the OS might use a page file, or swap partition, allowing the OS to move less used memory pages to disk and use the memory for something more useful. Again, if it does this, the PDT's have to be updated accordingly, and similar to memory mapped files, if the process tries to access pages that have been swapped out, it will trap into the OS which will bring the page back into memory. (While the ability to swap is often conflated with virtual memory per se, the fundamental idea behind virtual memory is the concept of the virtual addresses being distinct from physical memory addresses.)

share|improve this answer
    
I can choose not to have a page file or swap partition, how is virtual memory optional in that sense? At least if virtual memory is what the Google query "define:virtual memory" provides me... –  Tom Wijsman Aug 5 '10 at 23:21
    
@Tom I think janneb is saying the application has no choice to whether or not it exists in VRam or not. Not that you can't disable it. –  Jeff F. May 19 '11 at 20:15
    
@JeffF.: Applications do have a choice, it's just memory management. –  Tom Wijsman May 19 '11 at 20:17
    
@Tom :P I'm not arguing either way, just clarifying. –  Jeff F. May 19 '11 at 20:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.