title: how to determine if Java heap is using compressed pointers and whether or not resides at address 0 in memory?
body: <p>I am trying to follow up on some tips in this blog <a href="https://www.elastic.co/blog/a-heap-of-trouble#ref5" rel="nofollow noreferrer">https://www.elastic.co/blog/a-heap-of-trouble#ref5</a> which discusses the benefits of sizing one's Java heap so that (a) compressed pointers can be used (for heaps under 32GB) and (b) so that the heap resides at address 0 in memory.  The article details how compressed pointers allow more efficient  use of heap space, and explains that when the heap lives at address zero this  reduces the amount of arithmetic necessary to resolve pointer addresses.    Finally, the article says that if I use JVM options <code>-XX:+UnlockDiagnosticVMOptions</code> -<code>XX:+PrintCompressedOopsMode</code> I will see log output either like this:  </p>
  
  <p><code>heap address: 0x000000011be00000, size: 27648 MB, zero based Compressed Oops
  </code></p>
  
  <p>which indicates zero-based compressed oops are enabled, or output like this</p>
  
  <p><code>heap address: 0x0000000118400000, size: 28672 MB, Compressed Oops with base: 0x00000001183ff000
  </code></p>
  
  <p>Which indicates that the heap begins at an address other than zero, therefore requiring the aforementioned increase amount of arithmetic processing.  </p>
  
  <p>However, when I tried those options and grep'd through my application's (Elastic Search's) log directory I could find no such messages. If anyone could advise me on how I can force details of zero-based (or not zero based) compressed pointers to be logged I'd be very grateful.</p>
  
  <p>RESOLUTION: </p>
  
  <p>great answers !.. I accepted @apangin's and I wrapped the java program he provided in a shell script that can run as long as you have java.. which you should if you are looking at Java heap!  here is the script: <a href="https://github.com/buildlackey/scripts/blob/master/verify_compressed_pointers_from_zero_offset.sh" rel="nofollow noreferrer">https://github.com/buildlackey/scripts/blob/master/verify_compressed_pointers_from_zero_offset.sh</a></p>