src/hotspot/share/services/memoryService.cpp
author rkennke
Wed, 25 Oct 2017 10:05:17 +0200
changeset 47819 ee36a8e36561
parent 47622 817f2a7019e4
child 48168 cb5d2d4453d0
child 55934 912c55e702d6
permissions -rw-r--r--
8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass Reviewed-by: kbarrett, jgeorge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 35520
diff changeset
     2
 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4459
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4459
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4459
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    26
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    27
#include "classfile/vmSymbols.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    28
#include "gc/parallel/mutableSpace.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    29
#include "gc/serial/defNewGeneration.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    30
#include "gc/serial/tenuredGeneration.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    31
#include "gc/shared/collectorPolicy.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    32
#include "gc/shared/genCollectedHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    33
#include "gc/shared/generation.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    34
#include "gc/shared/generationSpec.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33794
diff changeset
    35
#include "logging/logConfiguration.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    36
#include "memory/heap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    37
#include "memory/memRegion.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    38
#include "oops/oop.inline.hpp"
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    39
#include "runtime/globals.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    40
#include "runtime/javaCalls.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    41
#include "services/classLoadingService.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    42
#include "services/lowMemoryDetector.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    43
#include "services/management.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    44
#include "services/memoryManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    45
#include "services/memoryPool.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    46
#include "services/memoryService.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    47
#include "utilities/growableArray.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
    48
#include "utilities/macros.hpp"
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
    49
#if INCLUDE_ALL_GCS
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    50
#include "gc/cms/concurrentMarkSweepGeneration.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    51
#include "gc/cms/parNewGeneration.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    52
#include "gc/g1/g1CollectedHeap.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    53
#include "gc/parallel/parallelScavengeHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    54
#include "gc/parallel/psOldGen.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30155
diff changeset
    55
#include "gc/parallel/psYoungGen.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    56
#include "services/g1MemoryPool.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    57
#include "services/psMemoryPool.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
    58
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
GrowableArray<MemoryPool*>* MemoryService::_pools_list =
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 9623
diff changeset
    61
  new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryPool*>(init_pools_list_size, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
GrowableArray<MemoryManager*>* MemoryService::_managers_list =
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 9623
diff changeset
    63
  new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryManager*>(init_managers_list_size, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    65
GCMemoryManager* MemoryService::_minor_gc_manager      = NULL;
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    66
GCMemoryManager* MemoryService::_major_gc_manager      = NULL;
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
    67
MemoryManager*   MemoryService::_code_cache_manager    = NULL;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
    68
GrowableArray<MemoryPool*>* MemoryService::_code_heap_pools =
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
    69
    new (ResourceObj::C_HEAP, mtInternal) GrowableArray<MemoryPool*>(init_code_heap_pools_size, true);
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    70
MemoryPool*      MemoryService::_metaspace_pool        = NULL;
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    71
MemoryPool*      MemoryService::_compressed_class_pool = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class GcThreadCountClosure: public ThreadClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  int _count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  GcThreadCountClosure() : _count(0) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  void do_thread(Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  int count() { return _count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
void GcThreadCountClosure::do_thread(Thread* thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  _count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
void MemoryService::set_universe_heap(CollectedHeap* heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  CollectedHeap::Name kind = heap->kind();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  switch (kind) {
47819
ee36a8e36561 8183542: Factor out serial GC specific code from GenCollectedHeap into its own subclass
rkennke
parents: 47622
diff changeset
    89
    case CollectedHeap::SerialHeap :
47622
817f2a7019e4 8179387: Factor out CMS specific code from GenCollectedHeap into its own subclass
rkennke
parents: 47216
diff changeset
    90
    case CollectedHeap::CMSHeap : {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      add_gen_collected_heap_info(GenCollectedHeap::heap());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
    94
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    case CollectedHeap::ParallelScavengeHeap : {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    99
    case CollectedHeap::G1CollectedHeap : {
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   100
      add_g1_heap_info(G1CollectedHeap::heap());
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   101
      break;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   102
    }
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   103
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    default: {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   105
      guarantee(false, "Unrecognized kind of heap");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // set the GC thread count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  GcThreadCountClosure gctcc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  heap->gc_threads_do(&gctcc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  int count = gctcc.count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  if (count > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    _minor_gc_manager->set_num_gc_threads(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    _major_gc_manager->set_num_gc_threads(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // All memory pools and memory managers are initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  _minor_gc_manager->initialize_gc_stat_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  _major_gc_manager->initialize_gc_stat_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
// Add memory pools for GenCollectedHeap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
// This function currently only supports two generations collected heap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
// The collector for GenCollectedHeap will have two memory managers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  CollectorPolicy* policy = heap->collector_policy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
24353
148147d21135 8027643: Merge GenCollectorPolicy and TwoGenerationCollectorPolicy
jwilhelm
parents: 22234
diff changeset
   130
  assert(policy->is_generation_policy(), "Only support two generations");
148147d21135 8027643: Merge GenCollectorPolicy and TwoGenerationCollectorPolicy
jwilhelm
parents: 22234
diff changeset
   131
  GenCollectorPolicy* gen_policy = policy->as_generation_policy();
148147d21135 8027643: Merge GenCollectorPolicy and TwoGenerationCollectorPolicy
jwilhelm
parents: 22234
diff changeset
   132
  if (gen_policy != NULL) {
29794
2dcbd946f9a8 8075635: Remove GenerationSpec array
jwilhelm
parents: 29684
diff changeset
   133
    Generation::Name kind = gen_policy->young_gen_spec()->name();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      case Generation::DefNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
        _minor_gc_manager = MemoryManager::get_copy_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
        break;
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   138
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      case Generation::ParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
        _minor_gc_manager = MemoryManager::get_parnew_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
        break;
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   142
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
        guarantee(false, "Unrecognized generation spec");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    if (policy->is_mark_sweep_policy()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      _major_gc_manager = MemoryManager::get_msc_memory_manager();
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   149
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    } else if (policy->is_concurrent_mark_sweep_policy()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
      _major_gc_manager = MemoryManager::get_cms_memory_manager();
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   152
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
      guarantee(false, "Unknown two-gen policy");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    guarantee(false, "Non two-gen policy");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  _managers_list->append(_minor_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  _managers_list->append(_major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
29684
a36d90acae41 8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents: 26796
diff changeset
   162
  add_generation_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
a36d90acae41 8057632: Remove auxiliary code used to handle the generations array
jwilhelm
parents: 26796
diff changeset
   163
  add_generation_memory_pool(heap->old_gen(), _major_gc_manager);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   166
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
// Add memory pools for ParallelScavengeHeap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
// This function currently only supports two generations collected heap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
// The collector for ParallelScavengeHeap will have two memory managers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  _managers_list->append(_minor_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  _managers_list->append(_major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
}
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   180
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   181
void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   182
  assert(UseG1GC, "sanity");
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   183
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   184
  _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager();
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   185
  _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   186
  _managers_list->append(_minor_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   187
  _managers_list->append(_major_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   188
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   189
  add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   190
  add_g1OldGen_memory_pool(g1h, _major_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   191
}
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   192
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
MemoryPool* MemoryService::add_gen(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
                                   const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
                                   bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
                                   bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
MemoryPool* MemoryService::add_space(ContiguousSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
                                     const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
                                     bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
                                     size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
                                     bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   217
MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* young_gen,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
                                               const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
                                               bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
                                               size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
                                               bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   223
  SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(young_gen, name, type, max_size, support_usage_threshold);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   229
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
                                         const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
                                         bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
                                         size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
                                         bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
}
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   240
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
// Add memory pool(s) for one generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
void MemoryService::add_generation_memory_pool(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
                                               MemoryManager* major_mgr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
                                               MemoryManager* minor_mgr) {
16362
7b5c4f403e90 8009156: [parfait] Null pointer deference in hotspot/src/share/vm/services/memoryService.cpp
morris
parents: 15482
diff changeset
   246
  guarantee(gen != NULL, "No generation for memory pool");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  Generation::Name kind = gen->kind();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  int index = _pools_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    case Generation::DefNew: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
      assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      DefNewGeneration* young_gen = (DefNewGeneration*) gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      // Add a memory pool for each space and young gen doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      // support low memory detection as it is expected to get filled up.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      MemoryPool* eden = add_space(young_gen->eden(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
                                   "Eden Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
                                   true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
                                   young_gen->max_eden_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
                                   false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
      MemoryPool* survivor = add_survivor_spaces(young_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
                                                 "Survivor Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
                                                 true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
                                                 young_gen->max_survivor_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
                                                 false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   269
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    case Generation::ParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
      assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
      // Add a memory pool for each space and young gen doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
      // support low memory detection as it is expected to get filled up.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      ParNewGeneration* parnew_gen = (ParNewGeneration*) gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
      MemoryPool* eden = add_space(parnew_gen->eden(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
                                   "Par Eden Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
                                   true /* is_heap */,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
                                   parnew_gen->max_eden_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
                                   false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
      MemoryPool* survivor = add_survivor_spaces(parnew_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
                                                 "Par Survivor Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
                                                 true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
                                                 parnew_gen->max_survivor_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
                                                 false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    }
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   289
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    case Generation::MarkSweepCompact: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
      assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
      add_gen(gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
              "Tenured Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
              true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
              true  /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   300
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    case Generation::ConcurrentMarkSweep:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
      assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
      ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      MemoryPool* pool = add_cms_space(cms->cmsSpace(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
                                       "CMS Old Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
                                       true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
                                       cms->reserved().byte_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
                                       true  /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    }
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   312
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
      assert(false, "should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
      // no memory pool added for others
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  assert(major_mgr != NULL, "Should have at least one manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  // Link managers and the memory pools together
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  for (int i = index; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    major_mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
    if (minor_mgr != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      minor_mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   332
#if INCLUDE_ALL_GCS
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   333
void MemoryService::add_psYoung_memory_pool(PSYoungGen* young_gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // Add a memory pool for each space and young gen doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  // support low memory detection as it is expected to get filled up.
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   338
  EdenMutableSpacePool* eden = new EdenMutableSpacePool(young_gen,
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   339
                                                        young_gen->eden_space(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
                                                        "PS Eden Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
                                                        MemoryPool::Heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
                                                        false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   344
  SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(young_gen,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
                                                                    "PS Survivor Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
                                                                    MemoryPool::Heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
                                                                    false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  major_mgr->add_pool(eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  major_mgr->add_pool(survivor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  minor_mgr->add_pool(eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  minor_mgr->add_pool(survivor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  _pools_list->append(eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  _pools_list->append(survivor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   357
void MemoryService::add_psOld_memory_pool(PSOldGen* old_gen, MemoryManager* mgr) {
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   358
  PSGenerationPool* old_gen_pool = new PSGenerationPool(old_gen,
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   359
                                                       "PS Old Gen",
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   360
                                                       MemoryPool::Heap,
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   361
                                                       true /* support_usage_threshold */);
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   362
  mgr->add_pool(old_gen_pool);
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   363
  _pools_list->append(old_gen_pool);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   366
void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   367
                                               MemoryManager* major_mgr,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   368
                                               MemoryManager* minor_mgr) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   369
  assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   370
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   371
  G1EdenPool* eden = new G1EdenPool(g1h);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   372
  G1SurvivorPool* survivor = new G1SurvivorPool(g1h);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   373
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   374
  major_mgr->add_pool(eden);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   375
  major_mgr->add_pool(survivor);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   376
  minor_mgr->add_pool(eden);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   377
  minor_mgr->add_pool(survivor);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   378
  _pools_list->append(eden);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   379
  _pools_list->append(survivor);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   380
}
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   381
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   382
void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   383
                                             MemoryManager* mgr) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   384
  assert(mgr != NULL, "should have one manager");
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   385
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   386
  G1OldGenPool* old_gen = new G1OldGenPool(g1h);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   387
  mgr->add_pool(old_gen);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   388
  _pools_list->append(old_gen);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   389
}
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   390
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   392
void MemoryService::add_code_heap_memory_pool(CodeHeap* heap, const char* name) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   393
  // Create new memory pool for this heap
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   394
  MemoryPool* code_heap_pool = new CodeHeapPool(heap, name, true /* support_usage_threshold */);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   395
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   396
  // Append to lists
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   397
  _code_heap_pools->append(code_heap_pool);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   398
  _pools_list->append(code_heap_pool);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   400
  if (_code_cache_manager == NULL) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   401
    // Create CodeCache memory manager
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   402
    _code_cache_manager = MemoryManager::get_code_cache_memory_manager();
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   403
    _managers_list->append(_code_cache_manager);
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   404
  }
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   405
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 25485
diff changeset
   406
  _code_cache_manager->add_pool(code_heap_pool);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   409
void MemoryService::add_metaspace_memory_pools() {
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   410
  MemoryManager* mgr = MemoryManager::get_metaspace_memory_manager();
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   411
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   412
  _metaspace_pool = new MetaspacePool();
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   413
  mgr->add_pool(_metaspace_pool);
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   414
  _pools_list->append(_metaspace_pool);
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   415
19979
ebe1dbb6e1aa 8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents: 18444
diff changeset
   416
  if (UseCompressedClassPointers) {
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   417
    _compressed_class_pool = new CompressedKlassSpacePool();
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   418
    mgr->add_pool(_compressed_class_pool);
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   419
    _pools_list->append(_compressed_class_pool);
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   420
  }
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   421
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   422
  _managers_list->append(mgr);
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   423
}
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   424
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  for (int i = 0; i < _managers_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    MemoryManager* mgr = _managers_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    if (mgr->is_manager(mh)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      return mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
MemoryPool* MemoryService::get_memory_pool(instanceHandle ph) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  for (int i = 0; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    if (pool->is_pool(ph)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      return pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
void MemoryService::track_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  // Track the peak memory usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  for (int i = 0; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    pool->record_peak_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  // Detect low memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  LowMemoryDetector::detect_low_memory();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
void MemoryService::track_memory_pool_usage(MemoryPool* pool) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  // Track the peak memory usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  pool->record_peak_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  // Detect low memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  if (LowMemoryDetector::is_enabled(pool)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    LowMemoryDetector::detect_low_memory(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   466
void MemoryService::gc_begin(bool fullGC, bool recordGCBeginTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   467
                             bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   468
                             bool recordPreGCUsage, bool recordPeakUsage) {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   469
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  GCMemoryManager* mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  if (fullGC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
    mgr = _major_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    mgr = _minor_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  assert(mgr->is_gc_memory_manager(), "Sanity check");
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   477
  mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  // Track the peak memory usage when GC begins
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   480
  if (recordPeakUsage) {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   481
    for (int i = 0; i < _pools_list->length(); i++) {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   482
      MemoryPool* pool = _pools_list->at(i);
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   483
      pool->record_peak_memory_usage();
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   484
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   488
void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   489
                           bool recordAccumulatedGCTime,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   490
                           bool recordGCEndTime, bool countCollection,
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   491
                           GCCause::Cause cause) {
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   492
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  GCMemoryManager* mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  if (fullGC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    mgr = (GCMemoryManager*) _major_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    mgr = (GCMemoryManager*) _minor_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  assert(mgr->is_gc_memory_manager(), "Sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  // register the GC end statistics and memory usage
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   502
  mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   503
              countCollection, cause);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
void MemoryService::oops_do(OopClosure* f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  for (i = 0; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    pool->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  for (i = 0; i < _managers_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    MemoryManager* mgr = _managers_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    mgr->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
bool MemoryService::set_verbose(bool verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  MutexLocker m(Management_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  // verbose will be set to the previous value
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33794
diff changeset
   522
  if (verbose) {
35520
0efb779f41a5 8147464: Use LogConfiguration::configure_stdout() instead of parse_log_arguments
brutisso
parents: 35228
diff changeset
   523
    LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33794
diff changeset
   524
  } else {
35520
0efb779f41a5 8147464: Use LogConfiguration::configure_stdout() instead of parse_log_arguments
brutisso
parents: 35228
diff changeset
   525
    LogConfiguration::configure_stdout(LogLevel::Off, true, LOG_TAGS(gc));
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33794
diff changeset
   526
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  ClassLoadingService::reset_trace_class_unloading();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  return verbose;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
46329
53ccc37bda19 8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents: 35520
diff changeset
   533
  InstanceKlass* ik = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  instanceHandle obj = ik->allocate_instance_handle(CHECK_NH);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  JavaValue result(T_VOID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  JavaCallArguments args(10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  args.push_oop(obj);                         // receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  args.push_long(usage.init_size_as_jlong()); // Argument 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  args.push_long(usage.used_as_jlong());      // Argument 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  args.push_long(usage.committed_as_jlong()); // Argument 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  args.push_long(usage.max_size_as_jlong());  // Argument 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  JavaCalls::call_special(&result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
                          ik,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   547
                          vmSymbols::object_initializer_name(),
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   548
                          vmSymbols::long_long_long_long_void_signature(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
                          &args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
                          CHECK_NH);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  return obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
}
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33105
diff changeset
   553
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   554
// GC manager type depends on the type of Generation. Depending on the space
32623
390a27af5657 8134626: Misc cleanups after generation array removal
jwilhelm
parents: 31373
diff changeset
   555
// availability and vm options the gc uses major gc manager or minor gc
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
// manager or both. The type of gc manager depends on the generation kind.
25485
9c3d427eed01 8034246: remove CMS and ParNew adaptive size policy code
jcoomes
parents: 24353
diff changeset
   557
// For DefNew and ParNew generation doing scavenge gc uses minor gc manager (so
9c3d427eed01 8034246: remove CMS and ParNew adaptive size policy code
jcoomes
parents: 24353
diff changeset
   558
// _fullGC is set to false ) and for other generation kinds doing
9c3d427eed01 8034246: remove CMS and ParNew adaptive size policy code
jcoomes
parents: 24353
diff changeset
   559
// mark-sweep-compact uses major gc manager (so _fullGC is set to true).
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   560
TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    case Generation::DefNew:
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   563
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
    case Generation::ParNew:
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   565
#endif // INCLUDE_ALL_GCS
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33105
diff changeset
   566
      _fullGC = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    case Generation::MarkSweepCompact:
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   569
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    case Generation::ConcurrentMarkSweep:
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   571
#endif // INCLUDE_ALL_GCS
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33105
diff changeset
   572
      _fullGC = true;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    default:
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33105
diff changeset
   575
      _fullGC = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
      assert(false, "Unrecognized gc generation kind.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  }
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   578
  // this has to be called in a stop the world pause and represent
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   579
  // an entire gc pause, start to finish:
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33105
diff changeset
   580
  initialize(_fullGC, cause, true, true, true, true, true, true, true);
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   581
}
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33105
diff changeset
   582
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   583
TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   584
                                                 GCCause::Cause cause,
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   585
                                                 bool recordGCBeginTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   586
                                                 bool recordPreGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   587
                                                 bool recordPeakUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   588
                                                 bool recordPostGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   589
                                                 bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   590
                                                 bool recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   591
                                                 bool countCollection) {
33794
41ef3dc95179 8140482: Various minor code improvements (runtime)
goetz
parents: 33105
diff changeset
   592
  initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   593
             recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   594
             countCollection);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
}
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   596
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   597
// for a subclass to create then initialize an instance before invoking
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   598
// the MemoryService
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   599
void TraceMemoryManagerStats::initialize(bool fullGC,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   600
                                         GCCause::Cause cause,
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   601
                                         bool recordGCBeginTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   602
                                         bool recordPreGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   603
                                         bool recordPeakUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   604
                                         bool recordPostGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   605
                                         bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   606
                                         bool recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   607
                                         bool countCollection) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  _fullGC = fullGC;
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   609
  _recordGCBeginTime = recordGCBeginTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   610
  _recordPreGCUsage = recordPreGCUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   611
  _recordPeakUsage = recordPeakUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   612
  _recordPostGCUsage = recordPostGCUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   613
  _recordAccumulatedGCTime = recordAccumulatedGCTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   614
  _recordGCEndTime = recordGCEndTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   615
  _countCollection = countCollection;
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   616
  _cause = cause;
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   617
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   618
  MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   619
                          _recordPreGCUsage, _recordPeakUsage);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
TraceMemoryManagerStats::~TraceMemoryManagerStats() {
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   623
  MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 8921
diff changeset
   624
                        _recordGCEndTime, _countCollection, _cause);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
}