UseCompressedOops JVM标记做什么?我应该在什么时候使用它?

时间:2022-09-11 10:39:36

What does the hotspot JVM flag -XX:+UseCompressedOops do and when should I use it? What sort of performance and memory-usage differences will I see when using it on a 64-bit Java instance (vs. not using it)?

hotspot JVM标记-XX:+UseCompressedOops做什么?我应该在什么时候使用它?当在64位Java实例上使用它时,我将看到什么样的性能和内存使用差异(而不是使用它)?

1 个解决方案

#1


72  

Most HotSpot JVM in the last year have had it on by default. This option allows references to be 32-bit in a 64-bit JVM and access close to 32 GB of heap. (more than 32-bit pointers can) (You can have near unlimited off heap memory as well). This can save a significant amount of memory and potentially improve performance.

去年大多数热点JVM都默认打开了它。此选项允许在64位JVM中引用为32位,并访问接近32gb的堆。(32位以上的指针可以)(您也可以拥有近乎无限的堆外内存)。这可以节省大量内存,并可能提高性能。

If you want to use this option I suggest you update to a version which has it on by default as there may have been a good reason, such as bugs, why it wasn't enabled previously. Try Java 6 update 23 or Java 7 update 5.

如果您想要使用这个选项,我建议您更新一个默认启用它的版本,因为可能有一个很好的原因,比如bug,为什么以前没有启用它。试试Java 6 update 23或Java 7 update 5。

In short, don't turn it on, use a version which has it on by default.

简而言之,不要打开它,使用默认打开的版本。


Update:

更新:

In Java 8 you have the option to set the -XX:ObjectAlignmentInBytes= and in fact if you heap size to 64 GB it will use -XX:ObjectAlignmentInBytes=16 and still use 32-bit references.

在Java 8中,您可以设置-XX: objectalimentinbytes =,事实上,如果您将大小堆为64 GB,它将使用-XX:ObjectAlignmentInBytes=16,并且仍然使用32位引用。

#1


72  

Most HotSpot JVM in the last year have had it on by default. This option allows references to be 32-bit in a 64-bit JVM and access close to 32 GB of heap. (more than 32-bit pointers can) (You can have near unlimited off heap memory as well). This can save a significant amount of memory and potentially improve performance.

去年大多数热点JVM都默认打开了它。此选项允许在64位JVM中引用为32位,并访问接近32gb的堆。(32位以上的指针可以)(您也可以拥有近乎无限的堆外内存)。这可以节省大量内存,并可能提高性能。

If you want to use this option I suggest you update to a version which has it on by default as there may have been a good reason, such as bugs, why it wasn't enabled previously. Try Java 6 update 23 or Java 7 update 5.

如果您想要使用这个选项,我建议您更新一个默认启用它的版本,因为可能有一个很好的原因,比如bug,为什么以前没有启用它。试试Java 6 update 23或Java 7 update 5。

In short, don't turn it on, use a version which has it on by default.

简而言之,不要打开它,使用默认打开的版本。


Update:

更新:

In Java 8 you have the option to set the -XX:ObjectAlignmentInBytes= and in fact if you heap size to 64 GB it will use -XX:ObjectAlignmentInBytes=16 and still use 32-bit references.

在Java 8中,您可以设置-XX: objectalimentinbytes =,事实上,如果您将大小堆为64 GB,它将使用-XX:ObjectAlignmentInBytes=16,并且仍然使用32位引用。