hotspot/src/share/vm/services/memoryService.hpp
author tonyp
Fri, 20 Nov 2009 14:47:01 -0500
changeset 4459 eb506d590394
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC Summary: It introduces the necessary memory pools for G1. Reviewed-by: mchung, ysr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// Forward declaration
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class MemoryPool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class MemoryManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class GCMemoryManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class CollectedHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class Generation;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class DefNewGeneration;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class PSYoungGen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class PSOldGen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class PSPermGen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class CodeHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class ContiguousSpace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class CompactibleFreeListSpace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class PermanentGenerationSpec;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class GenCollectedHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class ParallelScavengeHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class CompactingPermGenGen;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class CMSPermGenGen;
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    43
class G1CollectedHeap;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// VM Monitoring and Management Support
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class MemoryService : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    init_pools_list_size = 10,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    init_managers_list_size = 5
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // index for minor and major generations
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    minor = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    major = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    n_gens = 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  static GrowableArray<MemoryPool*>*    _pools_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  static GrowableArray<MemoryManager*>* _managers_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // memory managers for minor and major GC statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  static GCMemoryManager*               _major_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  static GCMemoryManager*               _minor_gc_manager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Code heap memory pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  static MemoryPool*                    _code_heap_pool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  static void add_generation_memory_pool(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
                                         MemoryManager* major_mgr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
                                         MemoryManager* minor_mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  static void add_generation_memory_pool(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
                                         MemoryManager* major_mgr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    add_generation_memory_pool(gen, major_mgr, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  static void add_compact_perm_gen_memory_pool(CompactingPermGenGen* perm_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
                                               MemoryManager* mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  static void add_cms_perm_gen_memory_pool(CMSPermGenGen* perm_gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
                                           MemoryManager* mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  static void add_psYoung_memory_pool(PSYoungGen* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
                                      MemoryManager* major_mgr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                                      MemoryManager* minor_mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  static void add_psOld_memory_pool(PSOldGen* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
                                    MemoryManager* mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  static void add_psPerm_memory_pool(PSPermGen* perm,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
                                     MemoryManager* mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    92
  static void add_g1YoungGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    93
                                         MemoryManager* major_mgr,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    94
                                         MemoryManager* minor_mgr);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    95
  static void add_g1OldGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    96
                                       MemoryManager* mgr);
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    97
  static void add_g1PermGen_memory_pool(G1CollectedHeap* g1h,
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
    98
                                        MemoryManager* mgr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  static MemoryPool* add_space(ContiguousSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                               const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                               bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
                               size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                               bool support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  static MemoryPool* add_survivor_spaces(DefNewGeneration* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
                                         const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
                                         bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
                                         size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
                                         bool support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  static MemoryPool* add_gen(Generation* gen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
                             const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
                             bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
                             bool support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  static MemoryPool* add_cms_space(CompactibleFreeListSpace* space,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
                                   const char* name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
                                   bool is_heap,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
                                   size_t max_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
                                   bool support_usage_threshold);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  static void add_gen_collected_heap_info(GenCollectedHeap* heap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  static void add_parallel_scavenge_heap_info(ParallelScavengeHeap* heap);
4459
eb506d590394 6815790: G1: Missing MemoryPoolMXBeans with -XX:+UseG1GC
tonyp
parents: 1
diff changeset
   122
  static void add_g1_heap_info(G1CollectedHeap* g1h);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  static void set_universe_heap(CollectedHeap* heap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  static void add_code_heap_memory_pool(CodeHeap* heap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  static MemoryPool*    get_memory_pool(instanceHandle pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  static MemoryManager* get_memory_manager(instanceHandle mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  static const int num_memory_pools() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    return _pools_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  static const int num_memory_managers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    return _managers_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  static MemoryPool* get_memory_pool(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    return _pools_list->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  static MemoryManager* get_memory_manager(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    return _managers_list->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  static void track_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  static void track_code_cache_memory_usage() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    track_memory_pool_usage(_code_heap_pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  static void track_memory_pool_usage(MemoryPool* pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  static void gc_begin(bool fullGC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  static void gc_end(bool fullGC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  static void oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  static bool get_verbose() { return PrintGC; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  static bool set_verbose(bool verbose);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // Create an instance of java/lang/management/MemoryUsage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
class TraceMemoryManagerStats : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  bool         _fullGC;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  TraceMemoryManagerStats(bool fullGC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  TraceMemoryManagerStats(Generation::Name kind);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  ~TraceMemoryManagerStats();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
};