# HG changeset patch # User tonyp # Date 1316626597 14400 # Node ID 90a451f6e3ebabf6e57909d05414e64f283bb3b2 # Parent 1fd33ec0e5f764263f9df18b0b9a1e744ba4866e 7091032: G1: assert failure when NewRatio is used Summary: The desired min / max heap sizes are miscalculated at initialization when NewRatio is used. The changeset also includes an additional small change to turn a print statement into a warning. Reviewed-by: johnc, jmasa, ysr, brutisso diff -r 1fd33ec0e5f7 -r 90a451f6e3eb hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Wed Sep 21 10:04:45 2011 -0700 +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Wed Sep 21 13:36:37 2011 -0400 @@ -459,15 +459,16 @@ // ParallelScavengeHeap::initialize()). We might change this in the // future, but it's a good start. class G1YoungGenSizer : public TwoGenerationCollectorPolicy { +private: + size_t size_to_region_num(size_t byte_size) { + return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes); + } public: G1YoungGenSizer() { initialize_flags(); initialize_size_info(); } - size_t size_to_region_num(size_t byte_size) { - return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes); - } size_t min_young_region_num() { return size_to_region_num(_min_gen0_size); } @@ -501,11 +502,10 @@ if (FLAG_IS_CMDLINE(NewRatio)) { if (FLAG_IS_CMDLINE(NewSize) || FLAG_IS_CMDLINE(MaxNewSize)) { - gclog_or_tty->print_cr("-XX:NewSize and -XX:MaxNewSize overrides -XX:NewRatio"); + warning("-XX:NewSize and -XX:MaxNewSize override -XX:NewRatio"); } else { // Treat NewRatio as a fixed size that is only recalculated when the heap size changes - size_t heap_regions = sizer.size_to_region_num(_g1->n_regions()); - update_young_list_size_using_newratio(heap_regions); + update_young_list_size_using_newratio(_g1->n_regions()); _using_new_ratio_calculations = true; } }