# HG changeset patch # User brutisso # Date 1338809374 -7200 # Node ID b9442ac22f59c7ec7ece6cd86d1ff595cc6e9de8 # Parent 37552638d24ae34e6642a8336132751db324c6d7 7173460: G1: java/lang/management/MemoryMXBean/CollectionUsageThreshold.java failes with G1 Summary: The scope of TraceMemoryManagerStats in G1CollectedHeap need to cover the call to G1MonitoringSupport::update_sizes() Reviewed-by: johnc, jmasa diff -r 37552638d24a -r b9442ac22f59 src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Jun 05 22:30:24 2012 +0200 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Jun 04 13:29:34 2012 +0200 @@ -1493,22 +1493,28 @@ JavaThread::dirty_card_queue_set().abandon_logs(); assert(!G1DeferredRSUpdate || (G1DeferredRSUpdate && (dirty_card_queue_set().completed_buffers_num() == 0)), "Should not be any"); - } - - _young_list->reset_sampled_info(); - // At this point there should be no regions in the - // entire heap tagged as young. - assert( check_young_list_empty(true /* check_heap */), - "young list should be empty at this point"); - - // Update the number of full collections that have been completed. - increment_old_marking_cycles_completed(false /* concurrent */); - - _hrs.verify_optional(); - verify_region_sets_optional(); - - print_heap_after_gc(); - g1mm()->update_sizes(); + + _young_list->reset_sampled_info(); + // At this point there should be no regions in the + // entire heap tagged as young. + assert( check_young_list_empty(true /* check_heap */), + "young list should be empty at this point"); + + // Update the number of full collections that have been completed. + increment_old_marking_cycles_completed(false /* concurrent */); + + _hrs.verify_optional(); + verify_region_sets_optional(); + + print_heap_after_gc(); + + // We must call G1MonitoringSupport::update_sizes() in the same scoping level + // as an active TraceMemoryManagerStats object (i.e. before the destructor for the + // TraceMemoryManagerStats is called) so that the G1 memory pools are updated + // before any GC notifications are raised. + g1mm()->update_sizes(); + } + post_full_gc_dump(); return true; @@ -3936,25 +3942,30 @@ gc_epilogue(false); } - } - - // The closing of the inner scope, immediately above, will complete - // logging at the "fine" level. The record_collection_pause_end() call - // above will complete logging at the "finer" level. - // - // It is not yet to safe, however, to tell the concurrent mark to - // start as we have some optional output below. We don't want the - // output from the concurrent mark thread interfering with this - // logging output either. - - _hrs.verify_optional(); - verify_region_sets_optional(); - - TASKQUEUE_STATS_ONLY(if (ParallelGCVerbose) print_taskqueue_stats()); - TASKQUEUE_STATS_ONLY(reset_taskqueue_stats()); - - print_heap_after_gc(); - g1mm()->update_sizes(); + + // The closing of the inner scope, immediately above, will complete + // logging at the "fine" level. The record_collection_pause_end() call + // above will complete logging at the "finer" level. + // + // It is not yet to safe, however, to tell the concurrent mark to + // start as we have some optional output below. We don't want the + // output from the concurrent mark thread interfering with this + // logging output either. + + _hrs.verify_optional(); + verify_region_sets_optional(); + + TASKQUEUE_STATS_ONLY(if (ParallelGCVerbose) print_taskqueue_stats()); + TASKQUEUE_STATS_ONLY(reset_taskqueue_stats()); + + print_heap_after_gc(); + + // We must call G1MonitoringSupport::update_sizes() in the same scoping level + // as an active TraceMemoryManagerStats object (i.e. before the destructor for the + // TraceMemoryManagerStats is called) so that the G1 memory pools are updated + // before any GC notifications are raised. + g1mm()->update_sizes(); + } if (G1SummarizeRSetStats && (G1SummarizeRSetStatsPeriod > 0) &&