64 位 JVM 的最大可能堆大小是多少? [英] What is the largest possible heap size with a 64-bit JVM?

查看:31
本文介绍了64 位 JVM 的最大可能堆大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 32 位系统中可以使用 -Xmx 设置的理论最大堆值当然是 2^32 字节,但通常(参见:了解最大 JVM 堆大小 - 32 位与 64 位) 不能全部使用4GB.

The theoretical maximum heap value that can be set with -Xmx in a 32-bit system is of course 2^32 bytes, but typically (see: Understanding max JVM heap size - 32bit vs 64bit) one cannot use all 4GB.

对于在 64 位机器上运行 64 位操作系统的 64 位 JVM,除了 2^64 字节或 16 艾字节的理论限制之外,还有什么限制吗?

For a 64-bit JVM running in a 64-bit OS on a 64-bit machine, is there any limit besides the theoretical limit of 2^64 bytes or 16 exabytes?

我知道出于各种原因(主要是垃圾收集),过大的堆可能不是明智的,但是鉴于阅读了具有 TB 级 RAM 的服务器,我想知道什么是>可能.

I know that for various reasons (mostly garbage collection), excessively large heaps might not be wise, but in light of reading about servers with terrabytes of RAM, I'm wondering what is possible.

推荐答案

如果你想使用 32 位引用,你的堆被限制为 32 GB.

If you want to use 32-bit references, your heap is limited to 32 GB.

但是,如果您愿意使用 64 位引用,那么大小可能会受您的操作系统限制,就像使用 32 位 JVM 一样.例如在 Windows 32 位上,这是 1.2 到 1.5 GB.

However, if you are willing to use 64-bit references, the size is likely to be limited by your OS, just as it is with 32-bit JVM. e.g. on Windows 32-bit this is 1.2 to 1.5 GB.

注意:您希望 JVM 堆适合主内存,最好在一个 NUMA 区域内.在较大的机器上大约为 1 TB.如果您的 JVM 跨越 NUMA 区域,则内存访问尤其是 GC 将花费更长的时间.如果您的 JVM 堆开始交换,则可能需要数小时才能进行 GC,或者甚至使您的机器无法使用,因为它会导致交换驱动器抖动.

Note: you will want your JVM heap to fit into main memory, ideally inside one NUMA region. That's about 1 TB on the bigger machines. If your JVM spans NUMA regions the memory access and the GC in particular will take much longer. If your JVM heap start swapping it might take hours to GC, or even make your machine unusable as it thrashes the swap drive.

注意:即使您在堆中使用 32 位引用,您也可以访问大的直接内存和内存映射大小.即使用远高于 32 GB.

Note: You can access large direct memory and memory mapped sizes even if you use 32-bit references in your heap. i.e. use well above 32 GB.

Hotspot JVM 中的压缩 oops

压缩的 oops 将托管指针(在 JVM 中的许多地方,但不是所有地方)表示为 32 位值,必须按 8 倍缩放并添加到 64 位基地址以找到它们引用的对象.这允许应用程序寻址多达 40 亿个对象(不是字节),或多达约 32Gb 的堆大小.同时,数据结构紧凑性与ILP32模式相比具有竞争力.

Compressed oops represent managed pointers (in many but not all places in the JVM) as 32-bit values which must be scaled by a factor of 8 and added to a 64-bit base address to find the object they refer to. This allows applications to address up to four billion objects (not bytes), or a heap size of up to about 32Gb. At the same time, data structure compactness is competitive with ILP32 mode.

这篇关于64 位 JVM 的最大可能堆大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆