virtual memory allocation
what are my options when i need to allocate virtual memory beyond the limits of system memory?
paging file is unlimited(limited by available disk space) so why could not i use it to allocate memory beyond the limits of physical memory limit or OS memory limits? why did they limit the virtual memory with the boundaries of address space? i know CPU could wo开发者_JAVA技巧rk with physical memory but why not OS handles this for me when i am accessing some portion of virtual memory?
The OS does take care of this for you. You do not have to think about when physical memory is fully utilized because the virtual memory system hides this from you. The limit on the address space of an application is a result of the number of bits that are allocated for storing memory addresses in the architecture.
Edit Re: comments
I think you may be confusing the amount of memory available to a given process with the total amount of virtual memory being managed by the OS, which is shared among processes. There is a limit on the total amount of committed virtual memory by all processes, but this commit limit is NOT the same as the address space limit for an individual process. The total commit limit is loosely the amount of physical memory + the pagefile size. So it's possible to tune your pagefile size to increase or decrease this number.
Bshields has the direct answer. I just wanted to add that if you're working on Windows, the esteemable Mark Russinovich has a very detailed and well written post on virtual memory here: http://blogs.technet.com/b/markrussinovich/archive/2008/11/17/3155406.aspx.
Virtual memory and address spaces are two separate notions. Memory paging is yet another thing.
The size of the address space is limited to the range locations that can be addressed. This is a limitation of the CPU and the mode it is operating in. For example, a typical 32-bit application running on a 64-bit system with 32 GB of memory still has a 32-bit address space. The fact that more storage is available doesn't change the fact that (ignoring for the simplicity the existence of PAE) the 32-bit program only uses 32-bit addresses.
Virtual memory is realy just the notion that the operating system can control a set of mappings between virtual memory pages and physical memory pages.
Memory paging allows the operating system to make it so that some of the virtual pages are stored on disk instead of physical memory. This can allow more virtual memory to be allocated than there is physical memory on a system.
精彩评论