Java – why can I set – Xmx to a value greater than physical and virtual memory on windows and Solaris?

On a 64 bit windows machine (each task manager) with 12gb ram and 33gb virtual memory, I was able to run Java (1.6.0_03-b05) with an impossible - Xmx setting of 3.5tb, but it failed 35TB What is the logic behind it when it works and fails? The 35 TB error seems to mean that it is trying to reserve space at startup Why does it do this for - Xmx instead of - XMS?

C:\temp>java -Xmx3500g ostest  
os.arch=amd64  
13781729280 Bytes RAM

C:\temp>java -Xmx35000g ostest  
Error occurred during initialization of VM  
Could not reserve enough space for object heap  
Could not create the Java virtual machine. 

On Solaris (4GB ram, Java 1.5.0_16), I almost gave up 1 Pb. I can set the height of - Xmx I don't understand the logic of when it will go wrong on the - Xmx setting

devsun1.mgo:/export/home/mgo> java -d64 -Xmx1000000g ostest
os.arch=sparcv9
4294967296 Bytes RAM

Solution

At least for sun 64 bit VM 1.6 on windows 0_ 17. Objectstartarray:: initialize will allocate 1 byte for every 512 bytes of heap at VM startup Starting VM with 35TB heap will cause VM to allocate 70gb immediately, resulting in system failure

When calculating the maximum heap, sun's 32-bit VM (and I think 64 bit VM) does not consider the available physical memory, but is limited to 2GB addressable memory on windows and Linux or 4GB on Solaris, or may not be able to allocate enough memory for the management area at startup

If you think about it, checking the maximum heap value doesn't make much sense for the integrity of available physical memory X GB of physical memory does not mean that x GB can be used for VM when needed. It can also be used by other processes. Therefore, VM needs a way to deal with the needs than the operating system anyway If the VM is not interrupted, outofmemoryerrors will be thrown if memory cannot be allocated from the OS, as if the maximum heap size has been reached

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>