Virtual memory really doesn't matter to you.
The main difference between 32-bit and 64-bit is that the address space in 64-bit mode is incredibly large. If 10 GiB looks a lot to you, note that .NET on a 64-bit version can use TiBs of memory like this. However, on the 32-bit version, .NET is much more conservative (and therefore the JVM) - the address space is 4 gigabytes - this is not so much.
But it does not matter - it does not matter. This simply simplifies programming and does not adversely affect the host OS. It creates a continuous address space for the virtual machine, which means you don’t need to fragment the heap (or, worse, a stack where it is more or less impossible), but they are usually only MiB or so), since you more "real" memory will be required. When you finally make virtual memory, it becomes a little more real - at this moment it needs more or less to be supported by some data storage - whether it is a page file (swap) or physical RAM.
The fact is that the physical location of the memory is not necessarily continuous, but this is done out of your reach, and the mapping is usually very fast. On the other hand, you need to, say, index an array that is actually fragmented into 10 different memory blocks of virtual addresses that (completely unnecessary) work.
So, you have it - virtual memory is almost free on 64-bit. The basic approach is "if it is there, use it." You do not limit other applications, and it saves you a lot of work if you really use it. But up to this point you have only a reservation. This does not mean any physical memory. You don’t pay for friends who could come tonight and sit at your table, but you still have a place for them to sit if they really come - and only when they finally arrive do you actually get “charged”.
See this question for more information on how Java behaves on different machines and in different versions: What is the default maximum heap size for the Sun JVM from Java SE 6? The maximum heap size also determines the amount of reserved virtual memory, since the heap must be a contiguous address space. If it had not been previously reserved, it might happen that the heap could not expand to this maximum value, because someone else had reserved the address space in the place where the heap should expand.
Luaan Apr 29 '14 at 15:53 2014-04-29 15:53
source share