Max memory for 64bit Java

heap-memory, java

Solution

Theoretically 264, but there might be limitations (obviously)

According to this FAQ it's only limited by memory and swap space on the local system:

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?

Also keep in mind you need to set the max heap via command line. Without an -Xmx command. without it Java uses 64mb + 30% = 83.2mb as a default max heap on 64 bit machines according the same FAQ.

java -Xmx1000g myClass 

works fine on my machine. But it dosn't seem to yet support the 't' modifier so you can't specify max memory in terabytes yet :)

Problem

What's the maximum amount of heap space that one can allocate for java on a 64-bit platform? Is it unlimited?

Original source