changeset 6483:9dfcd36b0adc

8043639: Backout JDK-8034852: Shrinking of Metaspace high-water-mark causes incorrect OutOfMemoryErrors or back-to-back GCs Reviewed-by: stefank, tschatzl
author ehelin
date Wed, 21 May 2014 16:11:04 +0200
parents 8ec72dcefd74
children 23a21eb6dcc3
files src/share/vm/memory/metaspace.cpp
diffstat 1 files changed, 5 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/memory/metaspace.cpp	Tue May 20 18:25:14 2014 +0400
+++ b/src/share/vm/memory/metaspace.cpp	Wed May 21 16:11:04 2014 +0200
@@ -1433,9 +1433,10 @@
   }
 
   size_t capacity_until_gc = capacity_until_GC();
-  assert(capacity_until_gc >= committed_bytes,
-         err_msg("capacity_until_gc: " SIZE_FORMAT " < committed_bytes: " SIZE_FORMAT,
-                 capacity_until_gc, committed_bytes));
+
+  if (capacity_until_gc <= committed_bytes) {
+    return 0;
+  }
 
   size_t left_until_GC = capacity_until_gc - committed_bytes;
   size_t left_to_commit = MIN2(left_until_GC, left_until_max);
@@ -1448,15 +1449,7 @@
   uint current_shrink_factor = _shrink_factor;
   _shrink_factor = 0;
 
-  // Using committed_bytes() for used_after_gc is an overestimation, since the
-  // chunk free lists are included in committed_bytes() and the memory in an
-  // un-fragmented chunk free list is available for future allocations.
-  // However, if the chunk free lists becomes fragmented, then the memory may
-  // not be available for future allocations and the memory is therefore "in use".
-  // Including the chunk free lists in the definition of "in use" is therefore
-  // necessary. Not including the chunk free lists can cause capacity_until_GC to
-  // shrink below committed_bytes() and this has caused serious bugs in the past.
-  const size_t used_after_gc = MetaspaceAux::committed_bytes();
+  const size_t used_after_gc = MetaspaceAux::capacity_bytes();
   const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
 
   const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;