hotspot/src/share/vm/services/memoryPool.cpp
author hseigel
Thu, 26 Sep 2013 10:25:02 -0400
changeset 20282 7f9cbdf89af2
parent 20001 7446501f55bc
child 23854 50f7f89b34e0
permissions -rw-r--r--
7195622: CheckUnhandledOops has limited usefulness now Summary: Enable CHECK_UNHANDLED_OOPS in fastdebug builds across all supported platforms. Reviewed-by: coleenp, hseigel, dholmes, stefank, twisti, ihse, rdurbin Contributed-by: lois.foltan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
20282
7f9cbdf89af2 7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents: 20001
diff changeset
     2
 * Copyright (c) 2003, 2013, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "classfile/vmSymbols.hpp"
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    28
#include "memory/metaspace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "runtime/javaCalls.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "services/lowMemoryDetector.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "services/management.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "services/memoryManager.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "services/memoryPool.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
    36
#include "utilities/macros.hpp"
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    37
#include "utilities/globalDefinitions.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
MemoryPool::MemoryPool(const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
                       PoolType type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
                       size_t init_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
                       size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
                       bool support_usage_threshold,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
                       bool support_gc_threshold) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  _name = name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  _initial_size = init_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  _max_size = max_size;
20282
7f9cbdf89af2 7195622: CheckUnhandledOops has limited usefulness now
hseigel
parents: 20001
diff changeset
    48
  (void)const_cast<instanceOop&>(_memory_pool_obj = NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  _available_for_allocation = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  _num_managers = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  _type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // initialize the max and init size of collection usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  _after_gc_usage = MemoryUsage(_initial_size, 0, 0, _max_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  _usage_sensor = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  _gc_usage_sensor = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // usage threshold supports both high and low threshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  _usage_threshold = new ThresholdSupport(support_usage_threshold, support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // gc usage threshold supports only high threshold
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  _gc_usage_threshold = new ThresholdSupport(support_gc_threshold, support_gc_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
void MemoryPool::add_manager(MemoryManager* mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  assert(_num_managers < MemoryPool::max_num_managers, "_num_managers exceeds the max");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  if (_num_managers < MemoryPool::max_num_managers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    _managers[_num_managers] = mgr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    _num_managers++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
// Returns an instanceHandle of a MemoryPool object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// It creates a MemoryPool instance when the first time
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// this function is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
instanceOop MemoryPool::get_memory_pool_instance(TRAPS) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Must do an acquire so as to force ordering of subsequent
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // loads from anything _memory_pool_obj points to or implies.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  instanceOop pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  if (pool_obj == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    // It's ok for more than one thread to execute the code up to the locked region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    // Extra pool instances will just be gc'ed.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 8921
diff changeset
    83
    Klass* k = Management::sun_management_ManagementFactory_klass(CHECK_NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    instanceKlassHandle ik(THREAD, k);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    Handle pool_name = java_lang_String::create_from_str(_name, CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    jlong usage_threshold_value = (_usage_threshold->is_high_threshold_supported() ? 0 : -1L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    jlong gc_usage_threshold_value = (_gc_usage_threshold->is_high_threshold_supported() ? 0 : -1L);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    JavaValue result(T_OBJECT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    JavaCallArguments args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    args.push_oop(pool_name);           // Argument 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    args.push_int((int) is_heap());     // Argument 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    95
    Symbol* method_name = vmSymbols::createMemoryPool_name();
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7397
diff changeset
    96
    Symbol* signature = vmSymbols::createMemoryPool_signature();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    args.push_long(usage_threshold_value);    // Argument 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    args.push_long(gc_usage_threshold_value); // Argument 4
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    JavaCalls::call_static(&result,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                           ik,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
                           method_name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                           signature,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                           &args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
                           CHECK_NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    instanceOop p = (instanceOop) result.get_jobject();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    instanceHandle pool(THREAD, p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      // Get lock since another thread may have create the instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      MutexLocker ml(Management_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      // Check if another thread has created the pool.  We reload
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
      // _memory_pool_obj here because some other thread may have
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      // initialized it while we were executing the code before the lock.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
      //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      // The lock has done an acquire, so the load can't float above it,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
      // but we need to do a load_acquire as above.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      if (pool_obj != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
         return pool_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
      // Get the address of the object we created via call_special.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      pool_obj = pool();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
      // Use store barrier to make sure the memory accesses associated
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      // with creating the pool are visible before publishing its address.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      // The unlock will publish the store to _memory_pool_obj because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
      // it does a release first.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      OrderAccess::release_store_ptr(&_memory_pool_obj, pool_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  return pool_obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
inline static size_t get_max_value(size_t val1, size_t val2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    return (val1 > val2 ? val1 : val2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
void MemoryPool::record_peak_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  // Caller in JDK is responsible for synchronization -
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // acquire the lock for this memory pool before calling VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  MemoryUsage usage = get_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  size_t peak_used = get_max_value(usage.used(), _peak_usage.used());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  size_t peak_committed = get_max_value(usage.committed(), _peak_usage.committed());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  size_t peak_max_size = get_max_value(usage.max_size(), _peak_usage.max_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  _peak_usage = MemoryUsage(initial_size(), peak_used, peak_committed, peak_max_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
static void set_sensor_obj_at(SensorInfo** sensor_ptr, instanceHandle sh) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  assert(*sensor_ptr == NULL, "Should be called only once");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  SensorInfo* sensor = new SensorInfo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  sensor->set_sensor(sh());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  *sensor_ptr = sensor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
void MemoryPool::set_usage_sensor_obj(instanceHandle sh) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  set_sensor_obj_at(&_usage_sensor, sh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
void MemoryPool::set_gc_usage_sensor_obj(instanceHandle sh) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  set_sensor_obj_at(&_gc_usage_sensor, sh);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
void MemoryPool::oops_do(OopClosure* f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  f->do_oop((oop*) &_memory_pool_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  if (_usage_sensor != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    _usage_sensor->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  if (_gc_usage_sensor != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    _gc_usage_sensor->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
ContiguousSpacePool::ContiguousSpacePool(ContiguousSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
                                         const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
                                         PoolType type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
                                         size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
                                         bool support_usage_threshold) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  CollectedMemoryPool(name, type, space->capacity(), max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
                      support_usage_threshold), _space(space) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
MemoryUsage ContiguousSpacePool::get_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  size_t maxSize   = (available_for_allocation() ? max_size() : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  size_t used      = used_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  size_t committed = _space->capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  return MemoryUsage(initial_size(), used, committed, maxSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
SurvivorContiguousSpacePool::SurvivorContiguousSpacePool(DefNewGeneration* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
                                                         const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
                                                         PoolType type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
                                                         size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
                                                         bool support_usage_threshold) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  CollectedMemoryPool(name, type, gen->from()->capacity(), max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
                      support_usage_threshold), _gen(gen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  size_t maxSize = (available_for_allocation() ? max_size() : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  size_t used    = used_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  size_t committed = committed_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  return MemoryUsage(initial_size(), used, committed, maxSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   214
#if INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
CompactibleFreeListSpacePool::CompactibleFreeListSpacePool(CompactibleFreeListSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
                                                           const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
                                                           PoolType type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
                                                           size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
                                                           bool support_usage_threshold) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  CollectedMemoryPool(name, type, space->capacity(), max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
                      support_usage_threshold), _space(space) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
MemoryUsage CompactibleFreeListSpacePool::get_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  size_t maxSize   = (available_for_allocation() ? max_size() : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  size_t used      = used_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  size_t committed = _space->capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  return MemoryUsage(initial_size(), used, committed, maxSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
}
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13728
diff changeset
   231
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
GenerationPool::GenerationPool(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
                               const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
                               PoolType type,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
                               bool support_usage_threshold) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  CollectedMemoryPool(name, type, gen->capacity(), gen->max_capacity(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
                      support_usage_threshold), _gen(gen) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
MemoryUsage GenerationPool::get_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  size_t used      = used_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  size_t committed = _gen->capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  size_t maxSize   = (available_for_allocation() ? max_size() : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  return MemoryUsage(initial_size(), used, committed, maxSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
CodeHeapPool::CodeHeapPool(CodeHeap* codeHeap, const char* name, bool support_usage_threshold) :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  MemoryPool(name, NonHeap, codeHeap->capacity(), codeHeap->max_capacity(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
             support_usage_threshold, false), _codeHeap(codeHeap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
MemoryUsage CodeHeapPool::get_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  size_t used      = used_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  size_t committed = _codeHeap->capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  size_t maxSize   = (available_for_allocation() ? max_size() : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  return MemoryUsage(initial_size(), used, committed, maxSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   261
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   262
MetaspacePool::MetaspacePool() :
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19979
diff changeset
   263
  MemoryPool("Metaspace", NonHeap, 0, calculate_max_size(), true, false) { }
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   264
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   265
MemoryUsage MetaspacePool::get_memory_usage() {
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19979
diff changeset
   266
  size_t committed = MetaspaceAux::committed_bytes();
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   267
  return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   268
}
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   269
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   270
size_t MetaspacePool::used_in_bytes() {
19343
5f9b3b1bb00e 8023219: NPG: MetaspaceMemoryPool should report statistics for all of metaspace
ehelin
parents: 18444
diff changeset
   271
  return MetaspaceAux::allocated_used_bytes();
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   272
}
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   273
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   274
size_t MetaspacePool::calculate_max_size() const {
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19979
diff changeset
   275
  return FLAG_IS_CMDLINE(MaxMetaspaceSize) ? MaxMetaspaceSize :
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19979
diff changeset
   276
                                             MemoryUsage::undefined_size();
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   277
}
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   278
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   279
CompressedKlassSpacePool::CompressedKlassSpacePool() :
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19979
diff changeset
   280
  MemoryPool("Compressed Class Space", NonHeap, 0, CompressedClassSpaceSize, true, false) { }
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   281
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   282
size_t CompressedKlassSpacePool::used_in_bytes() {
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   283
  return MetaspaceAux::allocated_used_bytes(Metaspace::ClassType);
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   284
}
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   285
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   286
MemoryUsage CompressedKlassSpacePool::get_memory_usage() {
20001
7446501f55bc 8024718: Metaspace performance counters and memory pools should report the same data
ehelin
parents: 19979
diff changeset
   287
  size_t committed = MetaspaceAux::committed_bytes(Metaspace::ClassType);
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   288
  return MemoryUsage(initial_size(), used_in_bytes(), committed, max_size());
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
   289
}