64 位 Java 的最大内存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2093679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 03:28:35  来源:igfitidea点击:

Max memory for 64bit Java

javaheap

提问by Raymond Barlow

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

在 64 位平台上可以为 java 分配的最大堆空间量是多少?是无限的吗?

采纳答案by Chad Okere

Theoretically 264, but there might be limitations (obviously)

理论上 2 64,但可能有限制(显然)

According to this FAQit'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?

在 64 位 VM 上,您可以使用 64 位寻址能力,从而导致最大 Java 堆大小仅受系统提供的物理内存和交换空间量的限制。

另请参阅为什么我不能使用 32 位 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.

还要记住,您需要通过命令行设置最大堆。没有 -Xmx 命令。如果没有它,Java 使用 64mb + 30% = 83.2mb 作为 64 位机器上的默认最大堆,根据相同的常见问题解答。

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

在我的机器上工作正常。但它似乎还不支持“t”修饰符,因此您还不能以 TB 为单位指定最大内存:)

回答by Paul Tomblin

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

如果你可以把宇宙中的每个原子都变成一个字节的 RAM,你就可以在 64 位地址空间中分配它。

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.

宇宙中有 10^80 个原子(根据 WolframAlpha),在 64 位系统中有 2^64 个字节的地址空间,所以你只能寻址每 5x10^60 个原子中的 1 个。但是如果你有 18 qintillion 字节的 RAM,你可能需要几个量子黑洞来为它供电。

回答by Stephen C

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

理论上它介于2^632^64字节之间。

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

实际上,它受机器上可用的物理内存和交换空间量的限制。而物理内存又受芯片组(即物理内存地址总线上的地址引脚数量)和主板(即 DIMM 插槽的数量和大小)的限制。

回答by RED SOFT ADAIR

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)

这可能取决于您的 VM 运行的系统。如果您运行的是 AMD x64 架构,则当前交付的处理器的地址空间使用 48 位,而不是 64。这导致理论上的最大值约为 256 TB。(见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. Probablythats what the VM will pass to your application depending on its configuration.

我不是虚拟机专家,但任何现代操作系统通常都会提供与物理 RAM 和可用虚拟内存一样多的内存。可能这就是 VM 将根据其配置传递给您的应用程序的内容。

回答by jarnbjo

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.

对于 Sun 最近的 VM,实际的堆限制大小通常是可用物理和/或虚拟内存的 512 倍。即使理论限制要高得多,VM 也会在启动时为每 512 字节堆内存分配 1 字节用于管理目的,因此 1TB 堆将立即需要 2GB 用于内存管理。