5

Please correct me if I'm wrong, but as far as I understand, starting from the Oracle HotSpot JVM 1.7 the 64bit version of JVM cannot run in "32 bit" mode any more (-d32 command line parameter).

I have heard, that in case when the JVM process is configured with less than 32Gb max heap the JVM automatically optimizes the memory usage by keeping 32bit pointers, etc. Is that correct? Does that still apply to 64bit Oracle HotSpot JVM? If yes, how can I switch this behavior off and disable the 32bit memory optimization?

Thank you!

Sergey Shcherbakov
  • 4,534
  • 4
  • 40
  • 65
  • 2
    The feature is called "compressed OOPs". Check out this thread: http://stackoverflow.com/questions/11054548/what-does-the-usecompressedoops-jvm-flag-do-and-when-should-i-use-it – Marko Topolnik Jan 15 '15 at 10:36
  • Great! Thanks, that looks to answer my question. – Sergey Shcherbakov Jan 15 '15 at 10:37
  • @MarkoTopolnik I was looking to provide a longer answer for questions raised which are not covered by your link. The OP askes at least 4 questions and has a number of misconceptions worth covering, but I can't be bothered putting them all as comments. – Peter Lawrey Jan 15 '15 at 10:45
  • 1
    @PeterLawrey I think you have the privilege to single-handedly reopen this question. I will not mind, of course :) – Marko Topolnik Jan 15 '15 at 10:50
  • @MarkoTopolnik This wasn't always the case, thank you for pointing this out to me. – Peter Lawrey Jan 15 '15 at 10:56

1 Answers1

4

In addition to the answer provided here What does the UseCompressedOops JVM flag do and when should I use it?

the 64bit version of JVM cannot run in "32 bit" mode any more

The 64 bit JVM only ever ran in 64 bit mode.

I have heard, that in case when the JVM process is configured with less than 32Gb max heap the JVM automatically optimizes the memory usage by keeping 32bit pointers,

When the heap is less than 32 GB (GB = giga-bytes, Gb = giga-bits) the JVM uses compressed Oops by default in Java 6, 7 and 8.

The JVM uses 32-bit references which are an index to the actual data. i.e. the number used might undergo significant translation to become the actual pointer. You can see this index using Unsafe.getInt().

The default limit for Compressed Oops Java 8 is 64 GB, and you can increase it to 128 GB by changing the object alignment, but it is rarely worth doing this as you lose too much memory to padding.

Does that still apply to 64bit Oracle HotSpot JVM? If yes, how can I switch this behavior off and disable the 32bit memory optimization?

It applies to the Oracle JVM and OpenJDK and you can turn it off using -XX:-UseCompressedOops but I can't imagine why you would want to.

Community
  • 1
  • 1
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130