tags:

views:

242

answers:

5

Hi,

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

Regards, Raymond Barlow

+1  A: 

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.

Paul Tomblin
@Stephen, I edited the answer before you posted your comment. WolframAlpha rules!
Paul Tomblin
Wouldn't want to wait for a full collect on that!
overthink
You need 266 bits to index every atom in the universe
Chad Okere
A: 

In theory its between 2^63 and 2^64 bytes.

In practice it is limited by the amount of physical memory and swap space available on your machine. And the physical memory is in turn limited by your chipset (i.e. the number of address pins on the physical memory address bus) and motherboard (i.e. the number and size of the DIMM sockets).

Stephen C
For AMD64, the current specs foresee 40-52 address pins. Also, they support NUMA architectures where each processor has a chunk of memory which other processors can only access indirectly.
MSalters
+1  A: 

This probably depends on the system your VM is running in. If you are running a AMD x64 architecture the address space of currently shipped processors uses 48 Bits, not 64. This results in a theoretical maximum of roughly 256 TB. (See http://en.wikipedia.org/wiki/X86-64)

I am not a specialist in VMs, but any modern OS typically will give as much memory as there is physical RAM plus available virtual memory. Probably thats what the VM will pass to your application depending on its configuration.

RED SOFT ADAIR
The relevant AMD manual states that the virtual address space is in fact 64 bits (Chapter 2.2.1, AMD64 Architecture Programmer’s Manual, v3.14, September 2007)
MSalters
+1  A: 

With recent VMs from Sun, the practical heap limit size is usually 512 times the available physical and/or virtual memory. Even if the theoretical limit is much higher, the VM will allocate 1 byte for maangement purposes for each 512 bytes of heap memory on startup, so 1TB of heap will immediately require 2GB for the memory management.

jarnbjo
+2  A: 
Chad Okere