hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
changeset 10529 9d5bbffbb322
parent 10528 06fab03478df
child 10664 702062c83bd7
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Sep 08 05:16:49 2011 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu Sep 08 16:29:41 2011 +0200
@@ -1682,7 +1682,7 @@
       }
       assert(curr == mr.end(), "post-condition");
     }
-    g1_policy()->calculate_reserve(n_regions());
+    g1_policy()->record_new_heap_size(n_regions());
   } else {
     ergo_verbose0(ErgoHeapSizing,
                   "did not expand the heap",
@@ -1733,7 +1733,7 @@
     _expansion_regions += num_regions_deleted;
     update_committed_space(old_end, new_end);
     HeapRegionRemSet::shrink_heap(n_regions());
-    g1_policy()->calculate_reserve(n_regions());
+    g1_policy()->record_new_heap_size(n_regions());
   } else {
     ergo_verbose0(ErgoHeapSizing,
                   "did not shrink the heap",
@@ -3525,6 +3525,19 @@
 
       init_mutator_alloc_region();
 
+      {
+        size_t expand_bytes = g1_policy()->expansion_amount();
+        if (expand_bytes > 0) {
+          size_t bytes_before = capacity();
+          if (!expand(expand_bytes)) {
+            // We failed to expand the heap so let's verify that
+            // committed/uncommitted amount match the backing store
+            assert(capacity() == _g1_storage.committed_size(), "committed size mismatch");
+            assert(max_capacity() == _g1_storage.reserved_size(), "reserved size mismatch");
+          }
+        }
+      }
+
       double end_time_sec = os::elapsedTime();
       double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS;
       g1_policy()->record_pause_time_ms(pause_time_ms);