Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max memory for 64bit Java

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

like image 257
Raymond Barlow Avatar asked Jan 19 '10 13:01

Raymond Barlow


People also ask

What is the max heap size for 64 bit JVM?

For 64 bit platforms and Java stacks in general, the recommended Maximum Heap range for WebSphere Application Server, would be between (4096M - 8192M) or (4G - 8G).

How much RAM can Java handle?

From the Java Tuning white paper: For a 32-bit process model, the maximum virtual address size of the process is typically 4 GB, though some operating systems limit this to 2 GB or 3 GB. The maximum heap size is typically -Xmx3800m (1600m) for 2 GB limits), though the actual limitation is application dependent.

How much memory should I allocate to Java?

Therefore we recommended that physical memory availability for each JVM be 4096 MB;0.5 GB is for JVM allocation and 512 MB is for overhead. This simplified calculation means that a 64-bit system with 16 GB physical memory can run 3 JVMs.

What is Max XMX in Java?

Sets the maximum memory size for the application (-Xmx >= -Xms). -Xmx size. size can be specified in megabytes (m) or gigabytes (g). For example: -Xmx2g sets a maximum heap size of 2GB.


2 Answers

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 :)

like image 136
Chad Okere Avatar answered Oct 20 '22 01:10

Chad Okere


If you could make every atom in the universe into a byte of RAM, you could allocate it in a 64 bit address space.

Actually, that's a slight exaggeration.

There are 10^80 atoms in the universe (according to WolframAlpha), and 2^64 bytes of address space in a 64 bit system, so you'd only be able to address 1 out of every 5x10^60 atoms. But if you have 18 qintillion bytes of RAM, you'd probably need a couple of quantum black holes to power it with.

like image 40
Paul Tomblin Avatar answered Oct 20 '22 02:10

Paul Tomblin