1.1 --- a/src/share/vm/memory/collectorPolicy.cpp Thu May 16 11:44:33 2013 +0100 1.2 +++ b/src/share/vm/memory/collectorPolicy.cpp Thu May 23 12:44:18 2013 +0100 1.3 @@ -264,6 +264,27 @@ 1.4 // need to do this again 1.5 MaxHeapSize = align_size_up(MaxHeapSize, max_alignment()); 1.6 1.7 + // adjust max heap size if necessary 1.8 + if (NewSize + OldSize > MaxHeapSize) { 1.9 + if (FLAG_IS_CMDLINE(MaxHeapSize)) { 1.10 + // somebody set a maximum heap size with the intention that we should not 1.11 + // exceed it. Adjust New/OldSize as necessary. 1.12 + uintx calculated_size = NewSize + OldSize; 1.13 + double shrink_factor = (double) MaxHeapSize / calculated_size; 1.14 + // align 1.15 + NewSize = align_size_down((uintx) (NewSize * shrink_factor), min_alignment()); 1.16 + // OldSize is already aligned because above we aligned MaxHeapSize to 1.17 + // max_alignment(), and we just made sure that NewSize is aligned to 1.18 + // min_alignment(). In initialize_flags() we verified that max_alignment() 1.19 + // is a multiple of min_alignment(). 1.20 + OldSize = MaxHeapSize - NewSize; 1.21 + } else { 1.22 + MaxHeapSize = NewSize + OldSize; 1.23 + } 1.24 + } 1.25 + // need to do this again 1.26 + MaxHeapSize = align_size_up(MaxHeapSize, max_alignment()); 1.27 + 1.28 always_do_update_barrier = UseConcMarkSweepGC; 1.29 1.30 // Check validity of heap flags 1.31 @@ -731,7 +752,7 @@ 1.32 // free memory should be here, especially if they are expensive. If this 1.33 // attempt fails, an OOM exception will be thrown. 1.34 { 1.35 - IntFlagSetting flag_change(MarkSweepAlwaysCompactCount, 1); // Make sure the heap is fully compacted 1.36 + UIntFlagSetting flag_change(MarkSweepAlwaysCompactCount, 1); // Make sure the heap is fully compacted 1.37 1.38 gch->do_collection(true /* full */, 1.39 true /* clear_all_soft_refs */, 1.40 @@ -856,7 +877,7 @@ 1.41 } 1.42 1.43 void MarkSweepPolicy::initialize_generations() { 1.44 - _generations = new GenerationSpecPtr[number_of_generations()]; 1.45 + _generations = NEW_C_HEAP_ARRAY3(GenerationSpecPtr, number_of_generations(), mtGC, 0, AllocFailStrategy::RETURN_NULL); 1.46 if (_generations == NULL) 1.47 vm_exit_during_initialization("Unable to allocate gen spec"); 1.48