UseCompressedOops JVM 标志有什么作用,我应该什么时候使用它? [英] What does the UseCompressedOops JVM flag do and when should I use it?

查看:40
本文介绍了UseCompressedOops JVM 标志有什么作用,我应该什么时候使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HotSpot JVM 标志 -XX:+UseCompressedOops 有什么作用?我应该什么时候使用它?在 64 位 Java 实例上使用它时(与不使用它相比),我会看到什么样的性能和内存使用差异?

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 都默认启用了它.此选项允许引用在 64 位 JVM 中为 32 位,并允许访问接近 32 GB 的堆.(超过 32 位指针可以)(您也可以拥有近乎无限的堆外内存).这可以节省大量内存并可能提高性能.

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.

如果你想使用这个选项,我建议你更新到一个默认启用它的版本,因为可能有一个很好的理由,比如错误,为什么以前没有启用它.尝试 Java 6 更新 23 或 Java 7 更新 5.

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.

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

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

更新:

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

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.

这篇关于UseCompressedOops JVM 标志有什么作用,我应该什么时候使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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