Why am I able to set -Xmx to a value greater than physical and virtual memory on the machine on both Windows and Solaris?

前端 未结 3 380
青春惊慌失措
青春惊慌失措 2020-12-09 20:22

On a 64-bit Windows machine with 12GB of RAM and 33GB of Virtual Memory (per Task Manager), I\'m able to run Java (1.6.0_03-b05) with an impossible -Xmx setting of 3.5TB but

3条回答
  •  我在风中等你
    2020-12-09 20:37

    According to this thread on Sun's java forums (the OP has 16GB of physical memory):

    You could specify -Xmx20g, but if the total of the memory needed by all the processes on your machine ever exceeds the physical memory on your machine, you are likely to end up paging. Some applications can survive running in paged memory, but the JVM isn't one of them. Your code might run okay, but, for example, garbage collections will be abysmally slow.

    UPDATE: I googled a bit further and, according to the Frequently Asked Questions About the Java HotSpot VM and more precisely How large a heap can I create using a 64-bit VM?

    How large a heap can I create using a 64-bit VM?

    On 64-bit VMs, you have 64 bits of addressability to work with resulting in a maximum Java heap size limited only by the amount of physical memory and swap space your system provides.
    See also Why can't I get a larger heap with the 32-bit JVM?

    I don't know why you are able to start a JVM with a heap >45GB. This is a bit confusing...

提交回复
热议问题