hotspot/src/share/vm/services/memoryService.cpp
author trims
Tue, 05 Apr 2011 14:12:31 -0700
changeset 8921 14bfe81f2a9d
parent 8076 96d498ec7ae1
child 9623 151c0b638488
permissions -rw-r--r--
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass Summary: Update the copyright to be 2010 on all changed files in OpenJDK Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8921
14bfe81f2a9d 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 8076
diff changeset
     2
 * Copyright (c) 2003, 2011, 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"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    28
#include "gc_implementation/shared/mutableSpace.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    29
#include "memory/collectorPolicy.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    30
#include "memory/defNewGeneration.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    31
#include "memory/genCollectedHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    32
#include "memory/generation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    33
#include "memory/generationSpec.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    34
#include "memory/heap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    35
#include "memory/memRegion.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    36
#include "memory/permGen.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    37
#include "memory/tenuredGeneration.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    38
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    39
#include "runtime/javaCalls.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    40
#include "services/classLoadingService.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    41
#include "services/lowMemoryDetector.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    42
#include "services/management.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    43
#include "services/memoryManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    44
#include "services/memoryPool.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    45
#include "services/memoryService.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    46
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    47
#ifndef SERIALGC
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    48
#include "gc_implementation/concurrentMarkSweep/cmsPermGen.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    49
#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    50
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    51
#include "gc_implementation/parNew/parNewGeneration.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    52
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    53
#include "gc_implementation/parallelScavenge/psOldGen.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    54
#include "gc_implementation/parallelScavenge/psPermGen.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    55
#include "gc_implementation/parallelScavenge/psYoungGen.hpp"
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"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    58
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
GrowableArray<MemoryPool*>* MemoryService::_pools_list =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  new (ResourceObj::C_HEAP) GrowableArray<MemoryPool*>(init_pools_list_size, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
GrowableArray<MemoryManager*>* MemoryService::_managers_list =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  new (ResourceObj::C_HEAP) GrowableArray<MemoryManager*>(init_managers_list_size, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
GCMemoryManager* MemoryService::_minor_gc_manager = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
GCMemoryManager* MemoryService::_major_gc_manager = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
MemoryPool*      MemoryService::_code_heap_pool   = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
class GcThreadCountClosure: public ThreadClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  int _count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  GcThreadCountClosure() : _count(0) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  void do_thread(Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  int count() { return _count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
void GcThreadCountClosure::do_thread(Thread* thread) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  _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 MemoryService::set_universe_heap(CollectedHeap* heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  CollectedHeap::Name kind = heap->kind();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    case CollectedHeap::GenCollectedHeap : {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      add_gen_collected_heap_info(GenCollectedHeap::heap());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    case CollectedHeap::ParallelScavengeHeap : {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      add_parallel_scavenge_heap_info(ParallelScavengeHeap::heap());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    94
    case CollectedHeap::G1CollectedHeap : {
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
    95
      add_g1_heap_info(G1CollectedHeap::heap());
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
    96
      break;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    97
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    default: {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   100
      guarantee(false, "Unrecognized kind of heap");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // set the GC thread count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  GcThreadCountClosure gctcc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  heap->gc_threads_do(&gctcc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  int count = gctcc.count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  if (count > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    _minor_gc_manager->set_num_gc_threads(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    _major_gc_manager->set_num_gc_threads(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // All memory pools and memory managers are initialized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  _minor_gc_manager->initialize_gc_stat_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  _major_gc_manager->initialize_gc_stat_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
// Add memory pools for GenCollectedHeap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// This function currently only supports two generations collected heap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
// The collector for GenCollectedHeap will have two memory managers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  CollectorPolicy* policy = heap->collector_policy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  assert(policy->is_two_generation_policy(), "Only support two generations");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  guarantee(heap->n_gens() == 2, "Only support two-generation heap");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  TwoGenerationCollectorPolicy* two_gen_policy = policy->as_two_generation_policy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  if (two_gen_policy != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    GenerationSpec** specs = two_gen_policy->generations();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    Generation::Name kind = specs[0]->name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      case Generation::DefNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
        _minor_gc_manager = MemoryManager::get_copy_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
      case Generation::ParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
      case Generation::ASParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        _minor_gc_manager = MemoryManager::get_parnew_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
      default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
        guarantee(false, "Unrecognized generation spec");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    if (policy->is_mark_sweep_policy()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      _major_gc_manager = MemoryManager::get_msc_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    } else if (policy->is_concurrent_mark_sweep_policy()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      _major_gc_manager = MemoryManager::get_cms_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      guarantee(false, "Unknown two-gen policy");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    guarantee(false, "Non two-gen policy");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  _managers_list->append(_minor_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  _managers_list->append(_major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  add_generation_memory_pool(heap->get_gen(minor), _major_gc_manager, _minor_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  add_generation_memory_pool(heap->get_gen(major), _major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  PermGen::Name name = policy->permanent_generation()->name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  switch (name) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    case PermGen::MarkSweepCompact: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      CompactingPermGenGen* perm_gen = (CompactingPermGenGen*) heap->perm_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      add_compact_perm_gen_memory_pool(perm_gen, _major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    case PermGen::ConcurrentMarkSweep: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      CMSPermGenGen* cms_gen = (CMSPermGenGen*) heap->perm_gen();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      add_cms_perm_gen_memory_pool(cms_gen, _major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      guarantee(false, "Unrecognized perm generation");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
// Add memory pools for ParallelScavengeHeap
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
// This function currently only supports two generations collected heap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
// The collector for ParallelScavengeHeap will have two memory managers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
void MemoryService::add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // Two managers to keep statistics about _minor_gc_manager and _major_gc_manager GC.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  _minor_gc_manager = MemoryManager::get_psScavenge_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  _major_gc_manager = MemoryManager::get_psMarkSweep_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  _managers_list->append(_minor_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  _managers_list->append(_major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  add_psYoung_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  add_psOld_memory_pool(heap->old_gen(), _major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  add_psPerm_memory_pool(heap->perm_gen(), _major_gc_manager);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
}
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   199
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   200
void MemoryService::add_g1_heap_info(G1CollectedHeap* g1h) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   201
  assert(UseG1GC, "sanity");
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   202
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   203
  _minor_gc_manager = MemoryManager::get_g1YoungGen_memory_manager();
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   204
  _major_gc_manager = MemoryManager::get_g1OldGen_memory_manager();
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   205
  _managers_list->append(_minor_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   206
  _managers_list->append(_major_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   207
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   208
  add_g1YoungGen_memory_pool(g1h, _major_gc_manager, _minor_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   209
  add_g1OldGen_memory_pool(g1h, _major_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   210
  add_g1PermGen_memory_pool(g1h, _major_gc_manager);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   211
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
MemoryPool* MemoryService::add_gen(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
                                   const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
                                   bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
                                   bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  GenerationPool* pool = new GenerationPool(gen, name, type, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
MemoryPool* MemoryService::add_space(ContiguousSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
                                     const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
                                     bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
                                     size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
                                     bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  ContiguousSpacePool* pool = new ContiguousSpacePool(space, name, type, max_size, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
MemoryPool* MemoryService::add_survivor_spaces(DefNewGeneration* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
                                               const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
                                               bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
                                               size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
                                               bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  SurvivorContiguousSpacePool* pool = new SurvivorContiguousSpacePool(gen, name, type, max_size, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
MemoryPool* MemoryService::add_cms_space(CompactibleFreeListSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
                                         const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
                                         bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
                                         size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
                                         bool support_usage_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  MemoryPool::PoolType type = (is_heap ? MemoryPool::Heap : MemoryPool::NonHeap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  CompactibleFreeListSpacePool* pool = new CompactibleFreeListSpacePool(space, name, type, max_size, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  _pools_list->append(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  return (MemoryPool*) pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
// Add memory pool(s) for one generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
void MemoryService::add_generation_memory_pool(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
                                               MemoryManager* major_mgr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
                                               MemoryManager* minor_mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  Generation::Name kind = gen->kind();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  int index = _pools_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    case Generation::DefNew: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
      assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
      DefNewGeneration* young_gen = (DefNewGeneration*) gen;
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
      MemoryPool* eden = add_space(young_gen->eden(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
                                   "Eden Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
                                   true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
                                   young_gen->max_eden_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
                                   false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
      MemoryPool* survivor = add_survivor_spaces(young_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
                                                 "Survivor Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
                                                 true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
                                                 young_gen->max_survivor_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
                                                 false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    case Generation::ParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    case Generation::ASParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
      assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
      // Add a memory pool for each space and young gen doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
      // support low memory detection as it is expected to get filled up.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      ParNewGeneration* parnew_gen = (ParNewGeneration*) gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
      MemoryPool* eden = add_space(parnew_gen->eden(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
                                   "Par Eden Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
                                   true /* is_heap */,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
                                   parnew_gen->max_eden_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
                                   false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
      MemoryPool* survivor = add_survivor_spaces(parnew_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
                                                 "Par Survivor Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
                                                 true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
                                                 parnew_gen->max_survivor_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
                                                 false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    case Generation::MarkSweepCompact: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      add_gen(gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
              "Tenured Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
              true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
              true  /* support_usage_threshold */);
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
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    case Generation::ConcurrentMarkSweep:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    case Generation::ASConcurrentMarkSweep:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      MemoryPool* pool = add_cms_space(cms->cmsSpace(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
                                       "CMS Old Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
                                       true, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
                                       cms->reserved().byte_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
                                       true  /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      assert(false, "should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      // no memory pool added for others
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  assert(major_mgr != NULL, "Should have at least one manager");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  // Link managers and the memory pools together
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  for (int i = index; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    major_mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    if (minor_mgr != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      minor_mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
void MemoryService::add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
                                                     MemoryManager* mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  PermanentGenerationSpec* spec = perm_gen->spec();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  size_t max_size = spec->max_size() - spec->read_only_size() - spec->read_write_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  MemoryPool* pool = add_space(perm_gen->unshared_space(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
                               "Perm Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
                                false, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
                                max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
                                true   /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  if (UseSharedSpaces) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    pool = add_space(perm_gen->ro_space(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
                     "Perm Gen [shared-ro]",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
                     false, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
                     spec->read_only_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
                     true   /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    pool = add_space(perm_gen->rw_space(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
                     "Perm Gen [shared-rw]",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
                     false, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
                     spec->read_write_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
                     true   /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
void MemoryService::add_cms_perm_gen_memory_pool(CMSPermGenGen* cms_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
                                                 MemoryManager* mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  MemoryPool* pool = add_cms_space(cms_gen->cmsSpace(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
                                   "CMS Perm Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
                                   false, /* is_heap */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
                                   cms_gen->reserved().byte_size(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
                                   true   /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  mgr->add_pool(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
void MemoryService::add_psYoung_memory_pool(PSYoungGen* gen, MemoryManager* major_mgr, MemoryManager* minor_mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  // Add a memory pool for each space and young gen doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  // support low memory detection as it is expected to get filled up.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  EdenMutableSpacePool* eden = new EdenMutableSpacePool(gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
                                                        gen->eden_space(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
                                                        "PS Eden Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
                                                        MemoryPool::Heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
                                                        false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  SurvivorMutableSpacePool* survivor = new SurvivorMutableSpacePool(gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
                                                                    "PS Survivor Space",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
                                                                    MemoryPool::Heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
                                                                    false /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  major_mgr->add_pool(eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  major_mgr->add_pool(survivor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  minor_mgr->add_pool(eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  minor_mgr->add_pool(survivor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  _pools_list->append(eden);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  _pools_list->append(survivor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
void MemoryService::add_psOld_memory_pool(PSOldGen* gen, MemoryManager* mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  PSGenerationPool* old_gen = new PSGenerationPool(gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
                                                   "PS Old Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
                                                   MemoryPool::Heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
                                                   true /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  mgr->add_pool(old_gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  _pools_list->append(old_gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
void MemoryService::add_psPerm_memory_pool(PSPermGen* gen, MemoryManager* mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  PSGenerationPool* perm_gen = new PSGenerationPool(gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
                                                    "PS Perm Gen",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
                                                    MemoryPool::NonHeap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
                                                    true /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  mgr->add_pool(perm_gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  _pools_list->append(perm_gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
}
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   432
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   433
void MemoryService::add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   434
                                               MemoryManager* major_mgr,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   435
                                               MemoryManager* minor_mgr) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   436
  assert(major_mgr != NULL && minor_mgr != NULL, "should have two managers");
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   437
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   438
  G1EdenPool* eden = new G1EdenPool(g1h);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   439
  G1SurvivorPool* survivor = new G1SurvivorPool(g1h);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   440
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   441
  major_mgr->add_pool(eden);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   442
  major_mgr->add_pool(survivor);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   443
  minor_mgr->add_pool(eden);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   444
  minor_mgr->add_pool(survivor);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   445
  _pools_list->append(eden);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   446
  _pools_list->append(survivor);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   447
}
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   448
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   449
void MemoryService::add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   450
                                             MemoryManager* mgr) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   451
  assert(mgr != NULL, "should have one manager");
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   452
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   453
  G1OldGenPool* old_gen = new G1OldGenPool(g1h);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   454
  mgr->add_pool(old_gen);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   455
  _pools_list->append(old_gen);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   456
}
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   457
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   458
void MemoryService::add_g1PermGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   459
                                              MemoryManager* mgr) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   460
  assert(mgr != NULL, "should have one manager");
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   461
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   462
  CompactingPermGenGen* perm_gen = (CompactingPermGenGen*) g1h->perm_gen();
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   463
  PermanentGenerationSpec* spec = perm_gen->spec();
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   464
  size_t max_size = spec->max_size() - spec->read_only_size()
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   465
                                     - spec->read_write_size();
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   466
  MemoryPool* pool = add_space(perm_gen->unshared_space(),
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   467
                               "G1 Perm Gen",
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   468
                               false, /* is_heap */
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   469
                               max_size,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   470
                               true   /* support_usage_threshold */);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   471
  mgr->add_pool(pool);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   472
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   473
  // in case we support CDS in G1
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   474
  if (UseSharedSpaces) {
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   475
    pool = add_space(perm_gen->ro_space(),
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   476
                     "G1 Perm Gen [shared-ro]",
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   477
                     false, /* is_heap */
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   478
                     spec->read_only_size(),
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   479
                     true   /* support_usage_threshold */);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   480
    mgr->add_pool(pool);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   481
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   482
    pool = add_space(perm_gen->rw_space(),
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   483
                     "G1 Perm Gen [shared-rw]",
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   484
                     false, /* is_heap */
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   485
                     spec->read_write_size(),
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   486
                     true   /* support_usage_threshold */);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   487
    mgr->add_pool(pool);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   488
  }
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1374
diff changeset
   489
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  _code_heap_pool = new CodeHeapPool(heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
                                     "Code Cache",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
                                     true /* support_usage_threshold */);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  MemoryManager* mgr = MemoryManager::get_code_cache_memory_manager();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  mgr->add_pool(_code_heap_pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  _pools_list->append(_code_heap_pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  _managers_list->append(mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
MemoryManager* MemoryService::get_memory_manager(instanceHandle mh) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  for (int i = 0; i < _managers_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    MemoryManager* mgr = _managers_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    if (mgr->is_manager(mh)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      return mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
MemoryPool* MemoryService::get_memory_pool(instanceHandle ph) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  for (int i = 0; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    if (pool->is_pool(ph)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
      return pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
void MemoryService::track_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  // Track the peak memory usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  for (int i = 0; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    pool->record_peak_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  // Detect low memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  LowMemoryDetector::detect_low_memory();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
void MemoryService::track_memory_pool_usage(MemoryPool* pool) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  // Track the peak memory usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  pool->record_peak_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  // Detect low memory
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  if (LowMemoryDetector::is_enabled(pool)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
    LowMemoryDetector::detect_low_memory(pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   544
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
   545
                             bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   546
                             bool recordPreGCUsage, bool recordPeakUsage) {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   547
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  GCMemoryManager* mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  if (fullGC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    mgr = _major_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    mgr = _minor_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  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
   555
  mgr->gc_begin(recordGCBeginTime, recordPreGCUsage, recordAccumulatedGCTime);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  // 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
   558
  if (recordPeakUsage) {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   559
    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
   560
      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
   561
      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
   562
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   566
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
   567
                           bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   568
                           bool recordGCEndTime, bool countCollection) {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   569
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  GCMemoryManager* mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  if (fullGC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    mgr = (GCMemoryManager*) _major_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    mgr = (GCMemoryManager*) _minor_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  assert(mgr->is_gc_memory_manager(), "Sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  // 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
   579
  mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   580
              countCollection);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
void MemoryService::oops_do(OopClosure* f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  for (i = 0; i < _pools_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
    MemoryPool* pool = _pools_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    pool->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  for (i = 0; i < _managers_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
    MemoryManager* mgr = _managers_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    mgr->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
bool MemoryService::set_verbose(bool verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  MutexLocker m(Management_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  // verbose will be set to the previous value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  bool succeed = CommandLineFlags::boolAtPut((char*)"PrintGC", &verbose, MANAGEMENT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  assert(succeed, "Setting PrintGC flag fails");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  ClassLoadingService::reset_trace_class_unloading();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  return verbose;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  klassOop k = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  instanceKlassHandle ik(THREAD, k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  instanceHandle obj = ik->allocate_instance_handle(CHECK_NH);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  JavaValue result(T_VOID);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  JavaCallArguments args(10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  args.push_oop(obj);                         // receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  args.push_long(usage.init_size_as_jlong()); // Argument 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  args.push_long(usage.used_as_jlong());      // Argument 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  args.push_long(usage.committed_as_jlong()); // Argument 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  args.push_long(usage.max_size_as_jlong());  // Argument 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  JavaCalls::call_special(&result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
                          ik,
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   622
                          vmSymbols::object_initializer_name(),
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
   623
                          vmSymbols::long_long_long_long_void_signature(),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
                          &args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
                          CHECK_NH);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  return obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
//
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   629
// GC manager type depends on the type of Generation. Depending on the space
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   630
// availablity and vm options the gc uses major gc manager or minor gc
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
// manager or both. The type of gc manager depends on the generation kind.
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   632
// For DefNew, ParNew and ASParNew generation doing scavenge gc uses minor
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   633
// gc manager (so _fullGC is set to false ) and for other generation kinds
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   634
// doing mark-sweep-compact uses major gc manager (so _fullGC is set
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
// to true).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
    case Generation::DefNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
    case Generation::ParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
    case Generation::ASParNew:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
      _fullGC=false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
    case Generation::MarkSweepCompact:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
#ifndef SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
    case Generation::ConcurrentMarkSweep:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    case Generation::ASConcurrentMarkSweep:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
#endif // SERIALGC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
      _fullGC=true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
      assert(false, "Unrecognized gc generation kind.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  }
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   655
  // 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
   656
  // an entire gc pause, start to finish:
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   657
  initialize(_fullGC, true, true, true, true, true, true, true);
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   658
}
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   659
TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   660
                                                 bool recordGCBeginTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   661
                                                 bool recordPreGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   662
                                                 bool recordPeakUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   663
                                                 bool recordPostGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   664
                                                 bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   665
                                                 bool recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   666
                                                 bool countCollection) {
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   667
  initialize(fullGC, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   668
             recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   669
             countCollection);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
}
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   671
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   672
// 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
   673
// the MemoryService
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   674
void TraceMemoryManagerStats::initialize(bool fullGC,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   675
                                         bool recordGCBeginTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   676
                                         bool recordPreGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   677
                                         bool recordPeakUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   678
                                         bool recordPostGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   679
                                         bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   680
                                         bool recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   681
                                         bool countCollection) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
  _fullGC = fullGC;
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   683
  _recordGCBeginTime = recordGCBeginTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   684
  _recordPreGCUsage = recordPreGCUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   685
  _recordPeakUsage = recordPeakUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   686
  _recordPostGCUsage = recordPostGCUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   687
  _recordAccumulatedGCTime = recordAccumulatedGCTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   688
  _recordGCEndTime = recordGCEndTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   689
  _countCollection = countCollection;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   690
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   691
  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
   692
                          _recordPreGCUsage, _recordPeakUsage);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
TraceMemoryManagerStats::~TraceMemoryManagerStats() {
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   696
  MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   697
                        _recordGCEndTime, _countCollection);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
}
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   699