diff src/share/vm/runtime/arguments.cpp @ 135:b7268662a986

6689523: max heap calculation for compressed oops is off by MaxPermSize Summary: Need to subtract MaxPermSize from the total heap size when determining whether compressed oops is turned on. Reviewed-by: jmasa, jcoomes, kvn
author coleenp
date Tue, 29 Apr 2008 19:31:29 -0400
parents ba764ed4b6f2
children 9148c65abefc 37f87013dfd8
line wrap: on
line diff
--- a/src/share/vm/runtime/arguments.cpp	Tue Apr 29 11:21:51 2008 -0400
+++ b/src/share/vm/runtime/arguments.cpp	Tue Apr 29 19:31:29 2008 -0400
@@ -1125,6 +1125,11 @@
   }
 }
 
+inline uintx max_heap_for_compressed_oops() {
+  LP64_ONLY(return oopDesc::OopEncodingHeapMax - MaxPermSize - os::vm_page_size());
+  NOT_LP64(return DefaultMaxRAM);
+}
+
 bool Arguments::should_auto_select_low_pause_collector() {
   if (UseAutoGCSelectPolicy &&
       !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
@@ -1169,7 +1174,7 @@
   // field offset to determine free list chunk markers.
   // Check that UseCompressedOops can be set with the max heap size allocated
   // by ergonomics.
-  if (!UseConcMarkSweepGC && MaxHeapSize <= (32*G - os::vm_page_size())) {
+  if (!UseConcMarkSweepGC && MaxHeapSize <= max_heap_for_compressed_oops()) {
     if (FLAG_IS_DEFAULT(UseCompressedOops)) {
       FLAG_SET_ERGO(bool, UseCompressedOops, true);
     }
@@ -1205,7 +1210,10 @@
     if (FLAG_IS_DEFAULT(MaxHeapSize)) {
       const uint64_t reasonable_fraction =
         os::physical_memory() / DefaultMaxRAMFraction;
-      const uint64_t maximum_size = (uint64_t) DefaultMaxRAM;
+      const uint64_t maximum_size = (uint64_t)
+                 (FLAG_IS_DEFAULT(DefaultMaxRAM) && UseCompressedOops ?
+                     MIN2(max_heap_for_compressed_oops(), DefaultMaxRAM) :
+                     DefaultMaxRAM);
       size_t reasonable_max =
         (size_t) os::allocatable_physical_memory(reasonable_fraction);
       if (reasonable_max > maximum_size) {