如果-d64开关对Sun JVM常驻内存使用有什么影响(如果有影响的话)?

时间:2021-12-24 02:40:45

I've got this webapp that needs some memory tuning. While I'm already profiling the application itself and trimming things down, the JVM itself seems overly bloated to me on our busiest instance. (The lower volume instances do not have this problem.) The details:

我有一个需要内存调优的webapp。虽然我已经对应用程序本身进行了剖析并进行了精简,但在我看来,在我们最繁忙的实例中,JVM本身似乎过于臃肿。(较低的卷实例没有这个问题。)细节:

  • Platform:
    • RHEL4 64-bit (Linux 2.6.9-78.0.5.ELsmp #1 SMP x86_64)
    • RHEL4 64位(Linux 2.6.9-78.0.5。ELsmp # 1 SMP x86_64)
    • Sun Java 6 (Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode))
    • Sun Java 6 (Java HotSpot(TM) 64位服务器VM(构建10.0-b23,混合模式)
    • Tomcat 6 with -d64 in startup.sh
    • Tomcat 6和-d64在启动阶段
  • 平台:RHEL4 64位(Linux 2.6.9-78.0.5)。SMP #1 SMP x86_64) Sun Java 6 (Java HotSpot(TM) 64位服务器VM(构建10.0-b23,混合模式)Tomcat 6和-d64
  • My webapp currently has some code that in production requires the benefits of running 64-bit.
  • 我的webapp目前有一些在生产中需要64位运行的代码。
  • I've observed that after some time (a week) the JVMs resident memory size (as shown by top) is three times the size of my -Xmx setting.
  • 我观察到,经过一段时间(一周)后,jvm驻留内存的大小(如顶部所示)是我的-Xmx设置的三倍。
  • The non-heap memory size, etc are all relatively trivial, a mere single digit percentage of the heap size
  • 非堆内存大小等都相对不重要,仅占堆大小的个位数百分比
  • There is only one section of code that requires a 64-bit bit address space
  • 只有一段代码需要64位地址空间

If I could refactor out the need for a 64-bit JVM, and drop the -d64 switch, would that make the JVM's resident memory footprint smaller? In other words...

如果我可以重构64位JVM的需求,并放弃-d64开关,那么JVM的驻留内存占用会不会更小?换句话说……

What impact, if any, does the -d64 switch have on the Sun JVM resident memory usage?

如果-d64开关对Sun JVM常驻内存使用有什么影响(如果有影响的话)?

1 个解决方案

#1


18  

Usage of the d64 switch gets the JVM into the 64-bit mode. Technically, on Solaris/Linux and most Unixes, the JVM process will execute in the LP64 model.

d64开关的使用使JVM进入64位模式。从技术上讲,在Solaris/Linux和大多数unix上,JVM进程将在LP64模型中执行。

The LP64 model is different from the 32-bit model (ILP32) in that pointers happen to be 64 bit wide as opposed to 32 bit pointers. For the JVM, this allows for greater memory addressability, but it also means that the size occupied by the object references alone has doubled. So there is greater bloat for the same number of objects at a given time in a 32-bit JVM and a 64-bit one.

LP64模型与32位模型(ILP32)不同,因为指针恰好是64位宽,而不是32位指针。对于JVM,这允许更大的内存寻址能力,但这也意味着仅由对象引用占用的大小就增加了一倍。所以在一个32位的JVM和64位的JVM中,相同数量的对象会有更大的膨胀。

Another thing that is often forgotten is the size of the instructions themselves. On a 64-bit JVM, the size of the instructions will occupy native machine register size.

另一件经常被遗忘的事情是指令本身的大小。在64位JVM上,指令的大小将占用本机机器寄存器大小。

If however, you use compressed object pointers in a 64-bit environment, the JVM will encode and decode pointers whenever possible for heap sizes greater than 4 GB. Briefly stated, when you use compressed pointers, the JVM attempts to use 32-bit wide values as much as possible.

但是,如果您在64位环境中使用压缩对象指针,JVM将尽可能地对大于4 GB的堆大小的指针进行编码和解码。简单地说,当您使用压缩指针时,JVM会尽量使用32位宽的值。

Hint: Switch on the UseCompressedOops flag, using -XX:+UseCompressedOops to get rid of some of the bloat. YMMV, but people have reported upto 50% drop in memory bloat by using compressed oops.

提示:打开UseCompressedOops标志,使用-XX:+UseCompressedOops消除一些肿胀。YMMV,但是人们报告说通过使用压缩哎呦,内存膨胀降低了50%。

EDIT

编辑

The UseCompressedOops flag is supported in version 14.0 of the Java HotSpot VM, available from Java 6 Update 14 onwards.

UseCompressedOops标志在Java HotSpot VM的14.0版本中得到支持,从Java 6 Update 14开始就可以使用。

#1


18  

Usage of the d64 switch gets the JVM into the 64-bit mode. Technically, on Solaris/Linux and most Unixes, the JVM process will execute in the LP64 model.

d64开关的使用使JVM进入64位模式。从技术上讲,在Solaris/Linux和大多数unix上,JVM进程将在LP64模型中执行。

The LP64 model is different from the 32-bit model (ILP32) in that pointers happen to be 64 bit wide as opposed to 32 bit pointers. For the JVM, this allows for greater memory addressability, but it also means that the size occupied by the object references alone has doubled. So there is greater bloat for the same number of objects at a given time in a 32-bit JVM and a 64-bit one.

LP64模型与32位模型(ILP32)不同,因为指针恰好是64位宽,而不是32位指针。对于JVM,这允许更大的内存寻址能力,但这也意味着仅由对象引用占用的大小就增加了一倍。所以在一个32位的JVM和64位的JVM中,相同数量的对象会有更大的膨胀。

Another thing that is often forgotten is the size of the instructions themselves. On a 64-bit JVM, the size of the instructions will occupy native machine register size.

另一件经常被遗忘的事情是指令本身的大小。在64位JVM上,指令的大小将占用本机机器寄存器大小。

If however, you use compressed object pointers in a 64-bit environment, the JVM will encode and decode pointers whenever possible for heap sizes greater than 4 GB. Briefly stated, when you use compressed pointers, the JVM attempts to use 32-bit wide values as much as possible.

但是,如果您在64位环境中使用压缩对象指针,JVM将尽可能地对大于4 GB的堆大小的指针进行编码和解码。简单地说,当您使用压缩指针时,JVM会尽量使用32位宽的值。

Hint: Switch on the UseCompressedOops flag, using -XX:+UseCompressedOops to get rid of some of the bloat. YMMV, but people have reported upto 50% drop in memory bloat by using compressed oops.

提示:打开UseCompressedOops标志,使用-XX:+UseCompressedOops消除一些肿胀。YMMV,但是人们报告说通过使用压缩哎呦,内存膨胀降低了50%。

EDIT

编辑

The UseCompressedOops flag is supported in version 14.0 of the Java HotSpot VM, available from Java 6 Update 14 onwards.

UseCompressedOops标志在Java HotSpot VM的14.0版本中得到支持,从Java 6 Update 14开始就可以使用。