Skip to content
Permalink
Browse files
8268952: Automatically update heap sizes in G1MonitoringScope
Reviewed-by: kbarrett, iwalulya
  • Loading branch information
Thomas Schatzl committed Jun 21, 2021
1 parent cbec37d commit a58c477c49ca595c65f7a2fca2512ff2adea99be
Showing 4 changed files with 7 additions and 11 deletions.
@@ -3067,12 +3067,6 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
print_heap_regions();
trace_heap_after_gc(_gc_tracer_stw);

// 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();

gc_tracer_report_gc_end(concurrent_operation_is_full_mark, evacuation_info);
}
// It should now be safe to tell the concurrent mark thread to start
@@ -51,11 +51,6 @@ G1FullGCScope::G1FullGCScope(G1MonitoringSupport* monitoring_support,
}

G1FullGCScope::~G1FullGCScope() {
// 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.
_g1h->g1mm()->update_sizes();
_g1h->trace_heap_after_gc(&_tracer);
_g1h->post_full_gc_dump(&_timer);
_timer.register_gc_end();
@@ -343,7 +343,12 @@ MemoryUsage G1MonitoringSupport::old_gen_memory_usage(size_t initial_size, size_
}

G1MonitoringScope::G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected) :
_g1mm(g1mm),
_tcs(full_gc ? g1mm->_full_collection_counters : g1mm->_incremental_collection_counters),
_tms(full_gc ? &g1mm->_full_gc_memory_manager : &g1mm->_incremental_memory_manager,
G1CollectedHeap::heap()->gc_cause(), all_memory_pools_affected) {
}

G1MonitoringScope::~G1MonitoringScope() {
_g1mm->update_sizes();
}
@@ -238,10 +238,12 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {

// Scope object for java.lang.management support.
class G1MonitoringScope : public StackObj {
G1MonitoringSupport* _g1mm;
TraceCollectorStats _tcs;
TraceMemoryManagerStats _tms;
public:
G1MonitoringScope(G1MonitoringSupport* g1mm, bool full_gc, bool all_memory_pools_affected);
~G1MonitoringScope();
};

#endif // SHARE_GC_G1_G1MONITORINGSUPPORT_HPP

0 comments on commit a58c477

Please sign in to comment.