--- old/src/hotspot/share/gc/cms/cmsHeap.cpp 2017-11-28 11:57:03.134782968 +0100 +++ new/src/hotspot/share/gc/cms/cmsHeap.cpp 2017-11-28 11:57:02.878785938 +0100 @@ -51,11 +51,11 @@ } MemoryUsage get_memory_usage() { - size_t maxSize = (available_for_allocation() ? max_size() : 0); + size_t max_heap_size = (available_for_allocation() ? max_size() : 0); size_t used = used_in_bytes(); size_t committed = _space->capacity(); - return MemoryUsage(initial_size(), used, committed, maxSize); + return MemoryUsage(initial_size(), used, committed, max_heap_size); } size_t used_in_bytes() { @@ -65,8 +65,8 @@ CMSHeap::CMSHeap(GenCollectorPolicy *policy) : GenCollectedHeap(policy), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL) { - _young_mgr = new GCMemoryManager("ParNew", "end of minor GC"); - _old_mgr = new GCMemoryManager("ConcurrentMarkSweep", "end of major GC"); + _young_manager = new GCMemoryManager("ParNew", "end of minor GC"); + _old_manager = new GCMemoryManager("ConcurrentMarkSweep", "end of major GC"); _workers = new WorkGang("GC Thread", ParallelGCThreads, /* are_GC_task_threads */true, @@ -102,12 +102,14 @@ old->reserved().byte_size(), true); - _young_mgr->add_pool(_eden_pool); - _young_mgr->add_pool(_survivor_pool); - - _old_mgr->add_pool(_eden_pool); - _old_mgr->add_pool(_survivor_pool); - _old_mgr->add_pool(_old_pool); + _young_manager->add_pool(_eden_pool); + _young_manager->add_pool(_survivor_pool); + young->set_gc_manager(_young_manager); + + _old_manager->add_pool(_eden_pool); + _old_manager->add_pool(_survivor_pool); + _old_manager->add_pool(_old_pool); + old ->set_gc_manager(_old_manager); return JNI_OK; } @@ -244,8 +246,8 @@ GrowableArray CMSHeap::memory_managers() { GrowableArray memory_managers(2); - memory_managers.append(_young_mgr); - memory_managers.append(_old_mgr); + memory_managers.append(_young_manager); + memory_managers.append(_old_manager); return memory_managers; } --- old/src/hotspot/share/gc/cms/cmsHeap.hpp 2017-11-28 11:57:03.726776100 +0100 +++ new/src/hotspot/share/gc/cms/cmsHeap.hpp 2017-11-28 11:57:03.471779059 +0100 @@ -98,7 +98,7 @@ OopsInGenClosure* root_closure, CLDClosure* cld_closure); - GCMemoryManager* old_mgr() const { return _old_mgr; } + GCMemoryManager* old_manager() const { return _old_manager; } private: WorkGang* _workers; --- old/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp 2017-11-28 11:57:04.313769290 +0100 +++ new/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp 2017-11-28 11:57:04.054772295 +0100 @@ -8116,42 +8116,42 @@ } TraceCMSMemoryManagerStats::TraceCMSMemoryManagerStats(CMSCollector::CollectorState phase, GCCause::Cause cause): TraceMemoryManagerStats() { - GCMemoryManager* mgr = CMSHeap::heap()->old_mgr(); + GCMemoryManager* manager = CMSHeap::heap()->old_manager(); switch (phase) { case CMSCollector::InitialMarking: - initialize(mgr /* GC manager */ , - cause /* cause of the GC */, - true /* recordGCBeginTime */, - true /* recordPreGCUsage */, - false /* recordPeakUsage */, - false /* recordPostGCusage */, - true /* recordAccumulatedGCTime */, - false /* recordGCEndTime */, - false /* countCollection */ ); + initialize(manager /* GC manager */ , + cause /* cause of the GC */, + true /* recordGCBeginTime */, + true /* recordPreGCUsage */, + false /* recordPeakUsage */, + false /* recordPostGCusage */, + true /* recordAccumulatedGCTime */, + false /* recordGCEndTime */, + false /* countCollection */ ); break; case CMSCollector::FinalMarking: - initialize(mgr /* GC manager */ , - cause /* cause of the GC */, - false /* recordGCBeginTime */, - false /* recordPreGCUsage */, - false /* recordPeakUsage */, - false /* recordPostGCusage */, - true /* recordAccumulatedGCTime */, - false /* recordGCEndTime */, - false /* countCollection */ ); + initialize(manager /* GC manager */ , + cause /* cause of the GC */, + false /* recordGCBeginTime */, + false /* recordPreGCUsage */, + false /* recordPeakUsage */, + false /* recordPostGCusage */, + true /* recordAccumulatedGCTime */, + false /* recordGCEndTime */, + false /* countCollection */ ); break; case CMSCollector::Sweeping: - initialize(mgr /* GC manager */ , - cause /* cause of the GC */, - false /* recordGCBeginTime */, - false /* recordPreGCUsage */, - true /* recordPeakUsage */, - true /* recordPostGCusage */, - false /* recordAccumulatedGCTime */, - true /* recordGCEndTime */, - true /* countCollection */ ); + initialize(manager /* GC manager */ , + cause /* cause of the GC */, + false /* recordGCBeginTime */, + false /* recordPreGCUsage */, + true /* recordPeakUsage */, + true /* recordPostGCusage */, + false /* recordAccumulatedGCTime */, + true /* recordGCEndTime */, + true /* countCollection */ ); break; default: --- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-28 11:57:04.943761981 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2017-11-28 11:57:04.689764928 +0100 @@ -1230,7 +1230,7 @@ const bool do_clear_all_soft_refs = clear_all_soft_refs || collector_policy()->should_clear_all_soft_refs(); - G1FullCollector collector(this, &_full_gc_mem_mgr, explicit_gc, do_clear_all_soft_refs); + G1FullCollector collector(this, &_full_gc_memory_manager, explicit_gc, do_clear_all_soft_refs); GCTraceTime(Info, gc) tm("Pause Full", NULL, gc_cause(), true); collector.prepare_collection(); @@ -1527,8 +1527,8 @@ CollectedHeap(), _young_gen_sampling_thread(NULL), _collector_policy(collector_policy), - _mem_mgr("G1 Young Generation", "end of minor GC"), - _full_gc_mem_mgr("G1 Old Generation", "end of major GC"), + _memory_manager("G1 Young Generation", "end of minor GC"), + _full_gc_memory_manager("G1 Old Generation", "end of major GC"), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL), @@ -1831,12 +1831,12 @@ _survivor_pool = new G1SurvivorPool(this); _old_pool = new G1OldGenPool(this); - _full_gc_mem_mgr.add_pool(_eden_pool); - _full_gc_mem_mgr.add_pool(_survivor_pool); - _full_gc_mem_mgr.add_pool(_old_pool); + _full_gc_memory_manager.add_pool(_eden_pool); + _full_gc_memory_manager.add_pool(_survivor_pool); + _full_gc_memory_manager.add_pool(_old_pool); - _mem_mgr.add_pool(_eden_pool); - _mem_mgr.add_pool(_survivor_pool); + _memory_manager.add_pool(_eden_pool); + _memory_manager.add_pool(_survivor_pool); G1StringDedup::initialize(); @@ -2971,7 +2971,7 @@ log_info(gc,task)("Using %u workers of %u for evacuation", active_workers, workers()->total_workers()); TraceCollectorStats tcs(g1mm()->incremental_collection_counters()); - TraceMemoryManagerStats tms(&_mem_mgr, gc_cause()); + TraceMemoryManagerStats tms(&_memory_manager, gc_cause()); // If the secondary_free_list is not empty, append it to the // free_list. No need to wait for the cleanup operation to finish; @@ -5388,8 +5388,8 @@ GrowableArray G1CollectedHeap::memory_managers() { GrowableArray memory_managers(2); - memory_managers.append(&_mem_mgr); - memory_managers.append(&_full_gc_mem_mgr); + memory_managers.append(&_memory_manager); + memory_managers.append(&_full_gc_memory_manager); return memory_managers; } --- old/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-28 11:57:05.567754741 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2017-11-28 11:57:05.304757792 +0100 @@ -151,8 +151,8 @@ WorkGang* _workers; G1CollectorPolicy* _collector_policy; - GCMemoryManager _mem_mgr; - GCMemoryManager _full_gc_mem_mgr; + GCMemoryManager _memory_manager; + GCMemoryManager _full_gc_memory_manager; MemoryPool* _eden_pool; MemoryPool* _survivor_pool; --- old/src/hotspot/share/gc/g1/g1FullCollector.cpp 2017-11-28 11:57:06.164747815 +0100 +++ new/src/hotspot/share/gc/g1/g1FullCollector.cpp 2017-11-28 11:57:05.909750773 +0100 @@ -71,9 +71,9 @@ return _heap->ref_processor_stw(); } -G1FullCollector::G1FullCollector(G1CollectedHeap* heap, GCMemoryManager* mem_mgr, bool explicit_gc, bool clear_soft_refs) : +G1FullCollector::G1FullCollector(G1CollectedHeap* heap, GCMemoryManager* memory_manager, bool explicit_gc, bool clear_soft_refs) : _heap(heap), - _scope(mem_mgr, explicit_gc, clear_soft_refs), + _scope(memory_manager, explicit_gc, clear_soft_refs), _num_workers(heap->workers()->active_workers()), _oop_queue_set(_num_workers), _array_queue_set(_num_workers), --- old/src/hotspot/share/gc/g1/g1FullCollector.hpp 2017-11-28 11:57:06.749741028 +0100 +++ new/src/hotspot/share/gc/g1/g1FullCollector.hpp 2017-11-28 11:57:06.493743998 +0100 @@ -57,7 +57,7 @@ ReferenceProcessorIsAliveMutator _is_alive_mutator; public: - G1FullCollector(G1CollectedHeap* heap, GCMemoryManager* mem_mgr, bool explicit_gc, bool clear_soft_refs); + G1FullCollector(G1CollectedHeap* heap, GCMemoryManager* memory_manager, bool explicit_gc, bool clear_soft_refs); ~G1FullCollector(); void prepare_collection(); --- old/src/hotspot/share/gc/g1/g1FullGCScope.cpp 2017-11-28 11:57:07.327734322 +0100 +++ new/src/hotspot/share/gc/g1/g1FullGCScope.cpp 2017-11-28 11:57:07.070737304 +0100 @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "gc/g1/g1FullGCScope.hpp" -G1FullGCScope::G1FullGCScope(GCMemoryManager* mem_mgr, bool explicit_gc, bool clear_soft) : +G1FullGCScope::G1FullGCScope(GCMemoryManager* memory_manager, bool explicit_gc, bool clear_soft) : _rm(), _explicit_gc(explicit_gc), _g1h(G1CollectedHeap::heap()), @@ -36,7 +36,7 @@ _active(), _cpu_time(), _soft_refs(clear_soft, _g1h->collector_policy()), - _memory_stats(mem_mgr, _g1h->gc_cause()), + _memory_stats(memory_manager, _g1h->gc_cause()), _collector_stats(_g1h->g1mm()->full_collection_counters()), _heap_transition(_g1h) { _timer.register_gc_start(); --- old/src/hotspot/share/gc/g1/g1FullGCScope.hpp 2017-11-28 11:57:07.910727558 +0100 +++ new/src/hotspot/share/gc/g1/g1FullGCScope.hpp 2017-11-28 11:57:07.654730528 +0100 @@ -56,7 +56,7 @@ G1HeapTransition _heap_transition; public: - G1FullGCScope(GCMemoryManager* mem_mgr, bool explicit_gc, bool clear_soft); + G1FullGCScope(GCMemoryManager* memory_manager, bool explicit_gc, bool clear_soft); ~G1FullGCScope(); bool is_explicit_gc(); --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2017-11-28 11:57:08.501720701 +0100 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp 2017-11-28 11:57:08.236723776 +0100 @@ -132,15 +132,15 @@ "PS Old Gen", true /* support_usage_threshold */); - _young_mgr = new GCMemoryManager("PS Scavenge", "end of minor GC"); - _old_mgr = new GCMemoryManager("PS MarkSweep", "end of major GC"); + _young_manager = new GCMemoryManager("PS Scavenge", "end of minor GC"); + _old_manager = new GCMemoryManager("PS MarkSweep", "end of major GC"); - _old_mgr->add_pool(_eden_pool); - _old_mgr->add_pool(_survivor_pool); - _old_mgr->add_pool(_old_pool); + _old_manager->add_pool(_eden_pool); + _old_manager->add_pool(_survivor_pool); + _old_manager->add_pool(_old_pool); - _young_mgr->add_pool(_eden_pool); - _young_mgr->add_pool(_survivor_pool); + _young_manager->add_pool(_eden_pool); + _young_manager->add_pool(_survivor_pool); return JNI_OK; } @@ -703,8 +703,8 @@ GrowableArray ParallelScavengeHeap::memory_managers() { GrowableArray memory_managers(2); - memory_managers.append(_young_mgr); - memory_managers.append(_old_mgr); + memory_managers.append(_young_manager); + memory_managers.append(_old_manager); return memory_managers; } --- old/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2017-11-28 11:57:09.093713833 +0100 +++ new/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp 2017-11-28 11:57:08.838716792 +0100 @@ -67,8 +67,8 @@ // The task manager static GCTaskManager* _gc_task_manager; - GCMemoryManager* _young_mgr; - GCMemoryManager* _old_mgr; + GCMemoryManager* _young_manager; + GCMemoryManager* _old_manager; MemoryPool* _eden_pool; MemoryPool* _survivor_pool; @@ -258,8 +258,8 @@ ~ParStrongRootsScope(); }; - GCMemoryManager* old_gc_mgr() const { return _old_mgr; } - GCMemoryManager* young_gc_mgr() const { return _young_mgr; } + GCMemoryManager* old_gc_manager() const { return _old_manager; } + GCMemoryManager* young_gc_manager() const { return _young_manager; } }; // Simple class for storing info about the heap at the start of GC, to be used --- old/src/hotspot/share/gc/parallel/psMarkSweep.cpp 2017-11-28 11:57:09.678707046 +0100 +++ new/src/hotspot/share/gc/parallel/psMarkSweep.cpp 2017-11-28 11:57:09.419710051 +0100 @@ -172,7 +172,7 @@ heap->pre_full_gc_dump(_gc_timer); TraceCollectorStats tcs(counters()); - TraceMemoryManagerStats tms(heap->old_gc_mgr(),gc_cause); + TraceMemoryManagerStats tms(heap->old_gc_manager(),gc_cause); if (log_is_enabled(Debug, gc, heap, exit)) { accumulated_time()->start(); --- old/src/hotspot/share/gc/parallel/psParallelCompact.cpp 2017-11-28 11:57:10.267700213 +0100 +++ new/src/hotspot/share/gc/parallel/psParallelCompact.cpp 2017-11-28 11:57:10.011703183 +0100 @@ -1772,7 +1772,7 @@ heap->pre_full_gc_dump(&_gc_timer); TraceCollectorStats tcs(counters()); - TraceMemoryManagerStats tms(heap->old_gc_mgr(), gc_cause); + TraceMemoryManagerStats tms(heap->old_gc_manager(), gc_cause); if (log_is_enabled(Debug, gc, heap, exit)) { accumulated_time()->start(); --- old/src/hotspot/share/gc/parallel/psScavenge.cpp 2017-11-28 11:57:10.868693240 +0100 +++ new/src/hotspot/share/gc/parallel/psScavenge.cpp 2017-11-28 11:57:10.612696210 +0100 @@ -305,7 +305,7 @@ GCTraceCPUTime tcpu; GCTraceTime(Info, gc) tm("Pause Young", NULL, gc_cause, true); TraceCollectorStats tcs(counters()); - TraceMemoryManagerStats tms(heap->young_gc_mgr(), gc_cause); + TraceMemoryManagerStats tms(heap->young_gc_manager(), gc_cause); if (log_is_enabled(Debug, gc, heap, exit)) { accumulated_time()->start(); --- old/src/hotspot/share/gc/serial/serialHeap.cpp 2017-11-28 11:57:11.467686291 +0100 +++ new/src/hotspot/share/gc/serial/serialHeap.cpp 2017-11-28 11:57:11.207689307 +0100 @@ -30,8 +30,8 @@ SerialHeap::SerialHeap(GenCollectorPolicy* policy) : GenCollectedHeap(policy), _eden_pool(NULL), _survivor_pool(NULL), _old_pool(NULL) { - _young_mgr = new GCMemoryManager("Copy", "end of minor GC"); - _old_mgr = new GCMemoryManager("MarkSweepCompact", "end of major GC"); + _young_manager = new GCMemoryManager("Copy", "end of minor GC"); + _old_manager = new GCMemoryManager("MarkSweepCompact", "end of major GC"); } jint SerialHeap::initialize() { @@ -50,14 +50,17 @@ "Survivor Space", young->max_survivor_size(), false /* support_usage_threshold */); - _old_pool = new GenerationPool(old_gen(), "Tenured Gen", true); + Generation* old = old_gen(); + _old_pool = new GenerationPool(old, "Tenured Gen", true); - _young_mgr->add_pool(_eden_pool); - _young_mgr->add_pool(_survivor_pool); - - _old_mgr->add_pool(_eden_pool); - _old_mgr->add_pool(_survivor_pool); - _old_mgr->add_pool(_old_pool); + _young_manager->add_pool(_eden_pool); + _young_manager->add_pool(_survivor_pool); + young->set_gc_manager(_young_manager); + + _old_manager->add_pool(_eden_pool); + _old_manager->add_pool(_survivor_pool); + _old_manager->add_pool(_old_pool); + old->set_gc_manager(_old_manager); return JNI_OK; } @@ -71,8 +74,8 @@ GrowableArray SerialHeap::memory_managers() { GrowableArray memory_managers(2); - memory_managers.append(_young_mgr); - memory_managers.append(_old_mgr); + memory_managers.append(_young_manager); + memory_managers.append(_old_manager); return memory_managers; } --- old/src/hotspot/share/gc/shared/genCollectedHeap.cpp 2017-11-28 11:57:12.060679411 +0100 +++ new/src/hotspot/share/gc/shared/genCollectedHeap.cpp 2017-11-28 11:57:11.803682392 +0100 @@ -264,13 +264,13 @@ _gc_cause == GCCause::_wb_full_gc; } -void GenCollectedHeap::collect_generation(Generation* gen, GCMemoryManager* mem_mgr, bool full, size_t size, +void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t size, bool is_tlab, bool run_verification, bool clear_soft_refs, bool restore_marks_for_biased_locking) { FormatBuffer<> title("Collect gen: %s", gen->short_name()); GCTraceTime(Trace, gc, phases) t1(title); TraceCollectorStats tcs(gen->counters()); - TraceMemoryManagerStats tmms(mem_mgr, gc_cause()); + TraceMemoryManagerStats tmms(gen->gc_manager(), gc_cause()); gen->stat_record()->invocations++; gen->stat_record()->accumulated_time.start(); @@ -414,7 +414,6 @@ } collect_generation(_young_gen, - _young_mgr, full, size, is_tlab, @@ -446,10 +445,10 @@ // We did a young GC. Need a new GC id for the old GC. GCIdMarkAndRestore gc_id_mark; GCTraceTime(Info, gc) t("Pause Full", NULL, gc_cause(), true); - collect_generation(_old_gen, _old_mgr, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true); + collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true); } else { // No young GC done. Use the same GC id as was set up earlier in this method. - collect_generation(_old_gen, _old_mgr, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true); + collect_generation(_old_gen, full, size, is_tlab, run_verification && VerifyGCLevel <= 1, do_clear_all_soft_refs, true); } must_restore_marks_for_biased_locking = true; --- old/src/hotspot/share/gc/shared/genCollectedHeap.hpp 2017-11-28 11:57:12.662672426 +0100 +++ new/src/hotspot/share/gc/shared/genCollectedHeap.hpp 2017-11-28 11:57:12.401675454 +0100 @@ -79,7 +79,7 @@ unsigned int _full_collections_completed; // Collects the given generation. - void collect_generation(Generation* gen, GCMemoryManager* mem_mgr, bool full, size_t size, bool is_tlab, + void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab, bool run_verification, bool clear_soft_refs, bool restore_marks_for_biased_locking); @@ -112,8 +112,8 @@ // (gen-specific) roots processing. SubTasksDone* _process_strong_tasks; - GCMemoryManager* _young_mgr; - GCMemoryManager* _old_mgr; + GCMemoryManager* _young_manager; + GCMemoryManager* _old_manager; // Helper functions for allocation HeapWord* attempt_allocation(size_t size, --- old/src/hotspot/share/gc/shared/generation.cpp 2017-11-28 11:57:13.245665663 +0100 +++ new/src/hotspot/share/gc/shared/generation.cpp 2017-11-28 11:57:12.986668667 +0100 @@ -44,7 +44,8 @@ #include "utilities/events.hpp" Generation::Generation(ReservedSpace rs, size_t initial_size) : - _ref_processor(NULL) { + _ref_processor(NULL), + _gc_manager(NULL) { if (!_virtual_space.initialize(rs, initial_size)) { vm_exit_during_initialization("Could not reserve enough space for " "object heap"); --- old/src/hotspot/share/gc/shared/generation.hpp 2017-11-28 11:57:13.834658829 +0100 +++ new/src/hotspot/share/gc/shared/generation.hpp 2017-11-28 11:57:13.572661869 +0100 @@ -86,6 +86,8 @@ MemRegion _prev_used_region; // for collectors that want to "remember" a value for // used region at some specific point during collection. + GCMemoryManager* _gc_manager; + protected: // Minimum and maximum addresses for memory reserved (not necessarily // committed) for generation. @@ -554,6 +556,16 @@ // Performance Counter support virtual void update_counters() = 0; virtual CollectorCounters* counters() { return _gc_counters; } + + GCMemoryManager* gc_manager() const { + assert(_gc_manager != NULL, "not initialized yet"); + return _gc_manager; + } + + void set_gc_manager(GCMemoryManager* gc_manager) { + _gc_manager = gc_manager; + } + }; #endif // SHARE_VM_GC_SHARED_GENERATION_HPP --- old/src/hotspot/share/services/memoryService.cpp 2017-11-28 11:57:14.420652030 +0100 +++ new/src/hotspot/share/services/memoryService.cpp 2017-11-28 11:57:14.160655047 +0100 @@ -76,15 +76,15 @@ heap->gc_threads_do(&gctcc); int count = gctcc.count(); - GrowableArray gc_mem_mgrs = heap->memory_managers(); - for (int i = 0; i < gc_mem_mgrs.length(); i++) { - GCMemoryManager* gc_mgr = gc_mem_mgrs.at(i); + GrowableArray gc_memory_managers = heap->memory_managers(); + for (int i = 0; i < gc_memory_managers.length(); i++) { + GCMemoryManager* gc_manager = gc_memory_managers.at(i); if (count > 0) { - gc_mgr->set_num_gc_threads(count); + gc_manager->set_num_gc_threads(count); } - gc_mgr->initialize_gc_stat_info(); - _managers_list->append(gc_mgr); + gc_manager->initialize_gc_stat_info(); + _managers_list->append(gc_manager); } } @@ -162,11 +162,11 @@ } } -void MemoryService::gc_begin(GCMemoryManager* mgr, bool recordGCBeginTime, +void MemoryService::gc_begin(GCMemoryManager* manager, bool recordGCBeginTime, bool recordAccumulatedGCTime, bool recordPreGCUsage, bool recordPeakUsage) { - mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime); + manager->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime); // Track the peak memory usage when GC begins if (recordPeakUsage) { @@ -177,13 +177,13 @@ } } -void MemoryService::gc_end(GCMemoryManager* mgr, bool recordPostGCUsage, +void MemoryService::gc_end(GCMemoryManager* manager, bool recordPostGCUsage, bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection, GCCause::Cause cause) { // register the GC end statistics and memory usage - mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, - countCollection, cause); + manager->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, + countCollection, cause); } void MemoryService::oops_do(OopClosure* f) { @@ -234,7 +234,7 @@ return obj; } -TraceMemoryManagerStats::TraceMemoryManagerStats(GCMemoryManager* gc_mem_mgr, +TraceMemoryManagerStats::TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager, GCCause::Cause cause, bool recordGCBeginTime, bool recordPreGCUsage, @@ -243,14 +243,14 @@ bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection) { - initialize(gc_mem_mgr, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, + initialize(gc_memory_manager, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage, recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime, countCollection); } // for a subclass to create then initialize an instance before invoking // the MemoryService -void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_mem_mgr, +void TraceMemoryManagerStats::initialize(GCMemoryManager* gc_memory_manager, GCCause::Cause cause, bool recordGCBeginTime, bool recordPreGCUsage, @@ -259,7 +259,7 @@ bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection) { - _gc_mem_mgr = gc_mem_mgr; + _gc_memory_manager = gc_memory_manager; _recordGCBeginTime = recordGCBeginTime; _recordPreGCUsage = recordPreGCUsage; _recordPeakUsage = recordPeakUsage; @@ -269,11 +269,11 @@ _countCollection = countCollection; _cause = cause; - MemoryService::gc_begin(_gc_mem_mgr, _recordGCBeginTime, _recordAccumulatedGCTime, + MemoryService::gc_begin(_gc_memory_manager, _recordGCBeginTime, _recordAccumulatedGCTime, _recordPreGCUsage, _recordPeakUsage); } TraceMemoryManagerStats::~TraceMemoryManagerStats() { - MemoryService::gc_end(_gc_mem_mgr, _recordPostGCUsage, _recordAccumulatedGCTime, + MemoryService::gc_end(_gc_memory_manager, _recordPostGCUsage, _recordAccumulatedGCTime, _recordGCEndTime, _countCollection, _cause); } --- old/src/hotspot/share/services/memoryService.hpp 2017-11-28 11:57:15.018645093 +0100 +++ new/src/hotspot/share/services/memoryService.hpp 2017-11-28 11:57:14.758648109 +0100 @@ -96,10 +96,10 @@ } static void track_memory_pool_usage(MemoryPool* pool); - static void gc_begin(GCMemoryManager* mgr, bool recordGCBeginTime, + static void gc_begin(GCMemoryManager* manager, bool recordGCBeginTime, bool recordAccumulatedGCTime, bool recordPreGCUsage, bool recordPeakUsage); - static void gc_end(GCMemoryManager* mgr, bool recordPostGCUsage, + static void gc_end(GCMemoryManager* manager, bool recordPostGCUsage, bool recordAccumulatedGCTime, bool recordGCEndTime, bool countCollection, GCCause::Cause cause); @@ -115,7 +115,7 @@ class TraceMemoryManagerStats : public StackObj { private: - GCMemoryManager* _gc_mem_mgr; + GCMemoryManager* _gc_memory_manager; bool _recordGCBeginTime; bool _recordPreGCUsage; bool _recordPeakUsage; @@ -126,7 +126,7 @@ GCCause::Cause _cause; public: TraceMemoryManagerStats() {} - TraceMemoryManagerStats(GCMemoryManager* gc_mem_mgr, + TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager, GCCause::Cause cause, bool recordGCBeginTime = true, bool recordPreGCUsage = true, @@ -136,7 +136,7 @@ bool recordGCEndTime = true, bool countCollection = true); - void initialize(GCMemoryManager* gc_mem_mgr, + void initialize(GCMemoryManager* gc_memory_manager, GCCause::Cause cause, bool recordGCBeginTime, bool recordPreGCUsage, --- /dev/null 2017-11-08 15:25:57.713133075 +0100 +++ new/test/hotspot/jtreg/gc/TestMemoryMXBeansAndPoolsPresence.java 2017-11-28 11:57:15.346641287 +0100 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.List; +import java.util.ArrayList; +import java.lang.management.*; +import static jdk.test.lib.Asserts.*; +import java.util.stream.*; + +/* @test TestMemoryMXBeansAndPoolsPresence + * @bug 8191564 + * @summary Tests that GarbageCollectorMXBeans and GC MemoryPools are created. + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run main/othervm -XX:+UseG1GC TestMemoryMXBeansAndPoolsPresence G1 + * @run main/othervm -XX:+UseConcMarkSweepGC TestMemoryMXBeansAndPoolsPresence CMS + * @run main/othervm -XX:+UseParallelGC TestMemoryMXBeansAndPoolsPresence Parallel + * @run main/othervm -XX:+UseSerialGC TestMemoryMXBeansAndPoolsPresence Serial + */ + +class GCBeanDescription { + public String name; + public String[] poolNames; + + public GCBeanDescription(String name, String[] poolNames) { + this.name = name; + this.poolNames = poolNames; + } +} + +public class TestMemoryMXBeansAndPoolsPresence { + public static void test(GCBeanDescription... expectedBeans) { + List memoryPools = ManagementFactory.getMemoryPoolMXBeans(); + + List gcBeans = ManagementFactory.getGarbageCollectorMXBeans(); + assertEQ(expectedBeans.length, gcBeans.size()); + + for (GCBeanDescription desc : expectedBeans) { + List beans = gcBeans.stream() + .filter(b -> b.getName().equals(desc.name)) + .collect(Collectors.toList()); + assertEQ(beans.size(), 1); + + GarbageCollectorMXBean bean = beans.get(0); + assertEQ(desc.name, bean.getName()); + + String[] pools = bean.getMemoryPoolNames(); + assertEQ(desc.poolNames.length, pools.length); + for (int i = 0; i < desc.poolNames.length; i++) { + assertEQ(desc.poolNames[i], pools[i]); + } + } + } + + public static void main(String[] args) { + switch (args[0]) { + case "G1": + test(new GCBeanDescription("G1 Young Generation", new String[] {"G1 Eden Space", "G1 Survivor Space"}), + new GCBeanDescription("G1 Old Generation", new String[] {"G1 Eden Space", "G1 Survivor Space", "G1 Old Gen"})); + break; + case "CMS": + test(new GCBeanDescription("ParNew", new String[] {"Par Eden Space", "Par Survivor Space"}), + new GCBeanDescription("ConcurrentMarkSweep", new String[] {"Par Eden Space", "Par Survivor Space", "CMS Old Gen"})); + break; + case "Parallel": + test(new GCBeanDescription("PS Scavenge", new String[] {"PS Eden Space", "PS Survivor Space"}), + new GCBeanDescription("PS MarkSweep", new String[] {"PS Eden Space", "PS Survivor Space", "PS Old Gen"})); + break; + case "Serial": + test(new GCBeanDescription("Copy", new String[] {"Eden Space", "Survivor Space"}), + new GCBeanDescription("MarkSweepCompact", new String[] {"Eden Space", "Survivor Space", "Tenured Gen"})); + break; + default: + assertTrue(false); + break; + + } + } +}