src/share/vm/services/memoryService.cpp

Mon, 05 Nov 2012 15:30:22 -0500

author
zgu
date
Mon, 05 Nov 2012 15:30:22 -0500
changeset 4248
69ad7823b1ca
parent 4037
da91efe96a93
child 4542
db9981fd3124
permissions
-rw-r--r--

8001591: NMT: assertion failed: assert(rec->addr() + rec->size() <= cur->base()) failed: Can not overlap in memSnapshot.cpp
Summary: NMT should allow overlapping committed regions as long as they belong to the same reserved region
Reviewed-by: dholmes, coleenp

     1 /*
     2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #include "precompiled.hpp"
    26 #include "classfile/systemDictionary.hpp"
    27 #include "classfile/vmSymbols.hpp"
    28 #include "gc_implementation/shared/mutableSpace.hpp"
    29 #include "memory/collectorPolicy.hpp"
    30 #include "memory/defNewGeneration.hpp"
    31 #include "memory/genCollectedHeap.hpp"
    32 #include "memory/generation.hpp"
    33 #include "memory/generationSpec.hpp"
    34 #include "memory/heap.hpp"
    35 #include "memory/memRegion.hpp"
    36 #include "memory/tenuredGeneration.hpp"
    37 #include "oops/oop.inline.hpp"
    38 #include "runtime/javaCalls.hpp"
    39 #include "services/classLoadingService.hpp"
    40 #include "services/lowMemoryDetector.hpp"
    41 #include "services/management.hpp"
    42 #include "services/memoryManager.hpp"
    43 #include "services/memoryPool.hpp"
    44 #include "services/memoryService.hpp"
    45 #include "utilities/growableArray.hpp"
    46 #ifndef SERIALGC
    47 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
    48 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
    49 #include "gc_implementation/parNew/parNewGeneration.hpp"
    50 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
    51 #include "gc_implementation/parallelScavenge/psOldGen.hpp"
    52 #include "gc_implementation/parallelScavenge/psYoungGen.hpp"
    53 #include "services/g1MemoryPool.hpp"
    54 #include "services/psMemoryPool.hpp"
    55 #endif
    57 GrowableArray<MemoryPool*>* MemoryService::_pools_list =
    58   new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryPool*>(init_pools_list_size, true);
    59 GrowableArray<MemoryManager*>* MemoryService::_managers_list =
    60   new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryManager*>(init_managers_list_size, true);
    62 GCMemoryManager* MemoryService::_minor_gc_manager = NULL;
    63 GCMemoryManager* MemoryService::_major_gc_manager = NULL;
    64 MemoryPool*      MemoryService::_code_heap_pool   = NULL;
    66 class GcThreadCountClosure: public ThreadClosure {
    67  private:
    68   int _count;
    69  public:
    70   GcThreadCountClosure() : _count(0) {};
    71   void do_thread(Thread* thread);
    72   int count() { return _count; }
    73 };
    75 void GcThreadCountClosure::do_thread(Thread* thread) {
    76   _count++;
    77 }
    79 void MemoryService::set_universe_heap(CollectedHeap* heap) {
    80   CollectedHeap::Name kind = heap->kind();
    81   switch (kind) {
    82     case CollectedHeap::GenCollectedHeap : {
    83       add_gen_collected_heap_info(GenCollectedHeap::heap());
    84       break;
    85     }
    86 #ifndef SERIALGC
    87     case CollectedHeap::ParallelScavengeHeap : {
    88       add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap());
    89       break;
    90     }
    91     case CollectedHeap::G1CollectedHeap : {
    92       add_g1_heap_info(G1CollectedHeap::heap());
    93       break;
    94     }
    95 #endif // SERIALGC
    96     default: {
    97       guarantee(false, "Unrecognized kind of heap");
    98     }
    99   }
   101   // set the GC thread count
   102   GcThreadCountClosure gctcc;
   103   heap->gc_threads_do(&gctcc);
   104   int count = gctcc.count();
   105   if (count > 0) {
   106     _minor_gc_manager->set_num_gc_threads(count);
   107     _major_gc_manager->set_num_gc_threads(count);
   108   }
   110   // All memory pools and memory managers are initialized.
   111   //
   112   _minor_gc_manager->initialize_gc_stat_info();
   113   _major_gc_manager->initialize_gc_stat_info();
   114 }
   116 // Add memory pools for GenCollectedHeap
   117 // This function currently only supports two generations collected heap.
   118 // The collector for GenCollectedHeap will have two memory managers.
   119 void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) {
   120   CollectorPolicy* policy = heap->collector_policy();
   122   assert(policy->is_two_generation_policy(), "Only support two generations");
   123   guarantee(heap->n_gens() == 2, "Only support two-generation heap");
   125   TwoGenerationCollectorPolicy* two_gen_policy = policy->as_two_generation_policy();
   126   if (two_gen_policy != NULL) {
   127     GenerationSpec** specs = two_gen_policy->generations();
   128     Generation::Name kind = specs[0]->name();
   129     switch (kind) {
   130       case Generation::DefNew:
   131         _minor_gc_manager = MemoryManager::get_copy_memory_manager();
   132         break;
   133 #ifndef SERIALGC
   134       case Generation::ParNew:
   135       case Generation::ASParNew:
   136         _minor_gc_manager = MemoryManager::get_parnew_memory_manager();
   137         break;
   138 #endif // SERIALGC
   139       default:
   140         guarantee(false, "Unrecognized generation spec");
   141         break;
   142     }
   143     if (policy->is_mark_sweep_policy()) {
   144       _major_gc_manager = MemoryManager::get_msc_memory_manager();
   145 #ifndef SERIALGC
   146     } else if (policy->is_concurrent_mark_sweep_policy()) {
   147       _major_gc_manager = MemoryManager::get_cms_memory_manager();
   148 #endif // SERIALGC
   149     } else {
   150       guarantee(false, "Unknown two-gen policy");
   151     }
   152   } else {
   153     guarantee(false, "Non two-gen policy");
   154   }
   155   _managers_list->append(_minor_gc_manager);
   156   _managers_list->append(_major_gc_manager);
   158   add_generation_memory_pool(heap->get_gen(minor), _major_gc_manager, _minor_gc_manager);
   159   add_generation_memory_pool(heap->get_gen(major), _major_gc_manager);
   160 }
   162 #ifndef SERIALGC
   163 // Add memory pools for ParallelScavengeHeap
   164 // This function currently only supports two generations collected heap.
   165 // The collector for ParallelScavengeHeap will have two memory managers.
   166 void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) {
   167   // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC.
   168   _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
   169   _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
   170   _managers_list->append(_minor_gc_manager);
   171   _managers_list->append(_major_gc_manager);
   173   add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
   174   add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
   175 }
   177 void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) {
   178   assert(UseG1GC, "sanity");
   180   _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager();
   181   _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
   182   _managers_list->append(_minor_gc_manager);
   183   _managers_list->append(_major_gc_manager);
   185   add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
   186   add_g1OldGen_memory_pool(g1h, _major_gc_manager);
   187 }
   188 #endif // SERIALGC
   190 MemoryPool* MemoryService::add_gen(Generation* gen,
   191                                    const char* name,
   192                                    bool is_heap,
   193                                    bool support_usage_threshold) {
   195   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
   196   GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
   197   _pools_list->append(pool);
   198   return (MemoryPool*) pool;
   199 }
   201 MemoryPool* MemoryService::add_space(ContiguousSpace* space,
   202                                      const char* name,
   203                                      bool is_heap,
   204                                      size_t max_size,
   205                                      bool support_usage_threshold) {
   206   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
   207   ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold);
   209   _pools_list->append(pool);
   210   return (MemoryPool*) pool;
   211 }
   213 MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* gen,
   214                                                const char* name,
   215                                                bool is_heap,
   216                                                size_t max_size,
   217                                                bool support_usage_threshold) {
   218   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
   219   SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(gen, name, type, max_size, support_usage_threshold);
   221   _pools_list->append(pool);
   222   return (MemoryPool*) pool;
   223 }
   225 #ifndef SERIALGC
   226 MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space,
   227                                          const char* name,
   228                                          bool is_heap,
   229                                          size_t max_size,
   230                                          bool support_usage_threshold) {
   231   MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
   232   CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold);
   233   _pools_list->append(pool);
   234   return (MemoryPool*) pool;
   235 }
   236 #endif // SERIALGC
   238 // Add memory pool(s) for one generation
   239 void MemoryService::add_generation_memory_pool(Generation* gen,
   240                                                MemoryManager* major_mgr,
   241                                                MemoryManager* minor_mgr) {
   242   Generation::Name kind = gen->kind();
   243   int index = _pools_list->length();
   245   switch (kind) {
   246     case Generation::DefNew: {
   247       assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
   248       DefNewGeneration* young_gen = (DefNewGeneration*) gen;
   249       // Add a memory pool for each space and young gen doesn't
   250       // support low memory detection as it is expected to get filled up.
   251       MemoryPool* eden = add_space(young_gen->eden(),
   252                                    "Eden Space",
   253                                    true, /* is_heap */
   254                                    young_gen->max_eden_size(),
   255                                    false /* support_usage_threshold */);
   256       MemoryPool* survivor = add_survivor_spaces(young_gen,
   257                                                  "Survivor Space",
   258                                                  true, /* is_heap */
   259                                                  young_gen->max_survivor_size(),
   260                                                  false /* support_usage_threshold */);
   261       break;
   262     }
   264 #ifndef SERIALGC
   265     case Generation::ParNew:
   266     case Generation::ASParNew:
   267     {
   268       assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
   269       // Add a memory pool for each space and young gen doesn't
   270       // support low memory detection as it is expected to get filled up.
   271       ParNewGeneration* parnew_gen = (ParNewGeneration*) gen;
   272       MemoryPool* eden = add_space(parnew_gen->eden(),
   273                                    "Par Eden Space",
   274                                    true /* is_heap */,
   275                                    parnew_gen->max_eden_size(),
   276                                    false /* support_usage_threshold */);
   277       MemoryPool* survivor = add_survivor_spaces(parnew_gen,
   278                                                  "Par Survivor Space",
   279                                                  true, /* is_heap */
   280                                                  parnew_gen->max_survivor_size(),
   281                                                  false /* support_usage_threshold */);
   283       break;
   284     }
   285 #endif // SERIALGC
   287     case Generation::MarkSweepCompact: {
   288       assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
   289       add_gen(gen,
   290               "Tenured Gen",
   291               true, /* is_heap */
   292               true  /* support_usage_threshold */);
   293       break;
   294     }
   296 #ifndef SERIALGC
   297     case Generation::ConcurrentMarkSweep:
   298     case Generation::ASConcurrentMarkSweep:
   299     {
   300       assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
   301       ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen;
   302       MemoryPool* pool = add_cms_space(cms->cmsSpace(),
   303                                        "CMS Old Gen",
   304                                        true, /* is_heap */
   305                                        cms->reserved().byte_size(),
   306                                        true  /* support_usage_threshold */);
   307       break;
   308     }
   309 #endif // SERIALGC
   311     default:
   312       assert(false, "should not reach here");
   313       // no memory pool added for others
   314       break;
   315   }
   317   assert(major_mgr != NULL, "Should have at least one manager");
   318   // Link managers and the memory pools together
   319   for (int i = index; i < _pools_list->length(); i++) {
   320     MemoryPool* pool = _pools_list->at(i);
   321     major_mgr->add_pool(pool);
   322     if (minor_mgr != NULL) {
   323       minor_mgr->add_pool(pool);
   324     }
   325   }
   326 }
   329 #ifndef SERIALGC
   330 void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) {
   331   assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
   333   // Add a memory pool for each space and young gen doesn't
   334   // support low memory detection as it is expected to get filled up.
   335   EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen,
   336                                                         gen->eden_space(),
   337                                                         "PS Eden Space",
   338                                                         MemoryPool::Heap,
   339                                                         false /* support_usage_threshold */);
   341   SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(gen,
   342                                                                     "PS Survivor Space",
   343                                                                     MemoryPool::Heap,
   344                                                                     false /* support_usage_threshold */);
   346   major_mgr->add_pool(eden);
   347   major_mgr->add_pool(survivor);
   348   minor_mgr->add_pool(eden);
   349   minor_mgr->add_pool(survivor);
   350   _pools_list->append(eden);
   351   _pools_list->append(survivor);
   352 }
   354 void MemoryService::add_psOld_memory_pool(PSOldGen* gen, MemoryManager* mgr) {
   355   PSGenerationPool* old_gen = new PSGenerationPool(gen,
   356                                                    "PS Old Gen",
   357                                                    MemoryPool::Heap,
   358                                                    true /* support_usage_threshold */);
   359   mgr->add_pool(old_gen);
   360   _pools_list->append(old_gen);
   361 }
   363 void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
   364                                                MemoryManager* major_mgr,
   365                                                MemoryManager* minor_mgr) {
   366   assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
   368   G1EdenPool* eden = new G1EdenPool(g1h);
   369   G1SurvivorPool* survivor = new G1SurvivorPool(g1h);
   371   major_mgr->add_pool(eden);
   372   major_mgr->add_pool(survivor);
   373   minor_mgr->add_pool(eden);
   374   minor_mgr->add_pool(survivor);
   375   _pools_list->append(eden);
   376   _pools_list->append(survivor);
   377 }
   379 void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
   380                                              MemoryManager* mgr) {
   381   assert(mgr != NULL, "should have one manager");
   383   G1OldGenPool* old_gen = new G1OldGenPool(g1h);
   384   mgr->add_pool(old_gen);
   385   _pools_list->append(old_gen);
   386 }
   387 #endif // SERIALGC
   389 void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) {
   390   _code_heap_pool = new CodeHeapPool(heap,
   391                                      "Code Cache",
   392                                      true /* support_usage_threshold */);
   393   MemoryManager* mgr = MemoryManager::get_code_cache_memory_manager();
   394   mgr->add_pool(_code_heap_pool);
   396   _pools_list->append(_code_heap_pool);
   397   _managers_list->append(mgr);
   398 }
   400 MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) {
   401   for (int i = 0; i < _managers_list->length(); i++) {
   402     MemoryManager* mgr = _managers_list->at(i);
   403     if (mgr->is_manager(mh)) {
   404       return mgr;
   405     }
   406   }
   407   return NULL;
   408 }
   410 MemoryPool* MemoryService::get_memory_pool(instanceHandle ph) {
   411   for (int i = 0; i < _pools_list->length(); i++) {
   412     MemoryPool* pool = _pools_list->at(i);
   413     if (pool->is_pool(ph)) {
   414       return pool;
   415     }
   416   }
   417   return NULL;
   418 }
   420 void MemoryService::track_memory_usage() {
   421   // Track the peak memory usage
   422   for (int i = 0; i < _pools_list->length(); i++) {
   423     MemoryPool* pool = _pools_list->at(i);
   424     pool->record_peak_memory_usage();
   425   }
   427   // Detect low memory
   428   LowMemoryDetector::detect_low_memory();
   429 }
   431 void MemoryService::track_memory_pool_usage(MemoryPool* pool) {
   432   // Track the peak memory usage
   433   pool->record_peak_memory_usage();
   435   // Detect low memory
   436   if (LowMemoryDetector::is_enabled(pool)) {
   437     LowMemoryDetector::detect_low_memory(pool);
   438   }
   439 }
   441 void MemoryService::gc_begin(bool fullGC, bool recordGCBeginTime,
   442                              bool recordAccumulatedGCTime,
   443                              bool recordPreGCUsage, bool recordPeakUsage) {
   445   GCMemoryManager* mgr;
   446   if (fullGC) {
   447     mgr = _major_gc_manager;
   448   } else {
   449     mgr = _minor_gc_manager;
   450   }
   451   assert(mgr->is_gc_memory_manager(), "Sanity check");
   452   mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime);
   454   // Track the peak memory usage when GC begins
   455   if (recordPeakUsage) {
   456     for (int i = 0; i < _pools_list->length(); i++) {
   457       MemoryPool* pool = _pools_list->at(i);
   458       pool->record_peak_memory_usage();
   459     }
   460   }
   461 }
   463 void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage,
   464                            bool recordAccumulatedGCTime,
   465                            bool recordGCEndTime, bool countCollection,
   466                            GCCause::Cause cause) {
   468   GCMemoryManager* mgr;
   469   if (fullGC) {
   470     mgr = (GCMemoryManager*) _major_gc_manager;
   471   } else {
   472     mgr = (GCMemoryManager*) _minor_gc_manager;
   473   }
   474   assert(mgr->is_gc_memory_manager(), "Sanity check");
   476   // register the GC end statistics and memory usage
   477   mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
   478               countCollection, cause);
   479 }
   481 void MemoryService::oops_do(OopClosure* f) {
   482   int i;
   484   for (i = 0; i < _pools_list->length(); i++) {
   485     MemoryPool* pool = _pools_list->at(i);
   486     pool->oops_do(f);
   487   }
   488   for (i = 0; i < _managers_list->length(); i++) {
   489     MemoryManager* mgr = _managers_list->at(i);
   490     mgr->oops_do(f);
   491   }
   492 }
   494 bool MemoryService::set_verbose(bool verbose) {
   495   MutexLocker m(Management_lock);
   496   // verbose will be set to the previous value
   497   bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, MANAGEMENT);
   498   assert(succeed, "Setting PrintGC flag fails");
   499   ClassLoadingService::reset_trace_class_unloading();
   501   return verbose;
   502 }
   504 Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
   505   Klass* k = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
   506   instanceKlassHandle ik(THREAD, k);
   508   instanceHandle obj = ik->allocate_instance_handle(CHECK_NH);
   510   JavaValue result(T_VOID);
   511   JavaCallArguments args(10);
   512   args.push_oop(obj);                         // receiver
   513   args.push_long(usage.init_size_as_jlong()); // Argument 1
   514   args.push_long(usage.used_as_jlong());      // Argument 2
   515   args.push_long(usage.committed_as_jlong()); // Argument 3
   516   args.push_long(usage.max_size_as_jlong());  // Argument 4
   518   JavaCalls::call_special(&result,
   519                           ik,
   520                           vmSymbols::object_initializer_name(),
   521                           vmSymbols::long_long_long_long_void_signature(),
   522                           &args,
   523                           CHECK_NH);
   524   return obj;
   525 }
   526 //
   527 // GC manager type depends on the type of Generation. Depending on the space
   528 // availablity and vm options the gc uses major gc manager or minor gc
   529 // manager or both. The type of gc manager depends on the generation kind.
   530 // For DefNew, ParNew and ASParNew generation doing scavenge gc uses minor
   531 // gc manager (so _fullGC is set to false ) and for other generation kinds
   532 // doing mark-sweep-compact uses major gc manager (so _fullGC is set
   533 // to true).
   534 TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) {
   535   switch (kind) {
   536     case Generation::DefNew:
   537 #ifndef SERIALGC
   538     case Generation::ParNew:
   539     case Generation::ASParNew:
   540 #endif // SERIALGC
   541       _fullGC=false;
   542       break;
   543     case Generation::MarkSweepCompact:
   544 #ifndef SERIALGC
   545     case Generation::ConcurrentMarkSweep:
   546     case Generation::ASConcurrentMarkSweep:
   547 #endif // SERIALGC
   548       _fullGC=true;
   549       break;
   550     default:
   551       assert(false, "Unrecognized gc generation kind.");
   552   }
   553   // this has to be called in a stop the world pause and represent
   554   // an entire gc pause, start to finish:
   555   initialize(_fullGC, cause,true, true, true, true, true, true, true);
   556 }
   557 TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
   558                                                  GCCause::Cause cause,
   559                                                  bool recordGCBeginTime,
   560                                                  bool recordPreGCUsage,
   561                                                  bool recordPeakUsage,
   562                                                  bool recordPostGCUsage,
   563                                                  bool recordAccumulatedGCTime,
   564                                                  bool recordGCEndTime,
   565                                                  bool countCollection) {
   566     initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
   567              recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
   568              countCollection);
   569 }
   571 // for a subclass to create then initialize an instance before invoking
   572 // the MemoryService
   573 void TraceMemoryManagerStats::initialize(bool fullGC,
   574                                          GCCause::Cause cause,
   575                                          bool recordGCBeginTime,
   576                                          bool recordPreGCUsage,
   577                                          bool recordPeakUsage,
   578                                          bool recordPostGCUsage,
   579                                          bool recordAccumulatedGCTime,
   580                                          bool recordGCEndTime,
   581                                          bool countCollection) {
   582   _fullGC = fullGC;
   583   _recordGCBeginTime = recordGCBeginTime;
   584   _recordPreGCUsage = recordPreGCUsage;
   585   _recordPeakUsage = recordPeakUsage;
   586   _recordPostGCUsage = recordPostGCUsage;
   587   _recordAccumulatedGCTime = recordAccumulatedGCTime;
   588   _recordGCEndTime = recordGCEndTime;
   589   _countCollection = countCollection;
   590   _cause = cause;
   592   MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime,
   593                           _recordPreGCUsage, _recordPeakUsage);
   594 }
   596 TraceMemoryManagerStats::~TraceMemoryManagerStats() {
   597   MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
   598                         _recordGCEndTime, _countCollection, _cause);
   599 }

mercurial