src/hotspot/share/services/memoryService.hpp
author stuefe
Tue, 26 Nov 2019 16:21:29 +0100
branchstuefe-new-metaspace-branch
changeset 59272 54750b448264
parent 53244 9807daeb47c4
permissions -rw-r--r--
Metadatatype back to metaspace.hpp to reduce patch size
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52200
diff changeset
     2
 * Copyright (c) 2003, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52200
diff changeset
    25
#ifndef SHARE_SERVICES_MEMORYSERVICE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52200
diff changeset
    26
#define SHARE_SERVICES_MEMORYSERVICE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29684
diff changeset
    28
#include "gc/shared/gcCause.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32623
diff changeset
    29
#include "logging/log.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    30
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    31
#include "runtime/handles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    32
#include "services/memoryUsage.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// Forward declaration
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class MemoryPool;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class MemoryManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class GCMemoryManager;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class CollectedHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class CodeHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// VM Monitoring and Management Support
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class MemoryService : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    init_pools_list_size = 10,
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    47
    init_managers_list_size = 5,
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    48
    init_code_heap_pools_size = 9
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  static GrowableArray<MemoryPool*>*    _pools_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  static GrowableArray<MemoryManager*>* _managers_list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    54
  // memory manager and code heap pools for the CodeCache
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    55
  static MemoryManager*                 _code_cache_manager;
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    56
  static GrowableArray<MemoryPool*>*    _code_heap_pools;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    58
  static MemoryPool*                    _metaspace_pool;
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    59
  static MemoryPool*                    _compressed_class_pool;
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    60
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  static void set_universe_heap(CollectedHeap* heap);
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    63
  static void add_code_heap_memory_pool(CodeHeap* heap, const char* name);
18444
8adb4bc92f18 8013590: NPG: Add a memory pool MXBean for Metaspace
ehelin
parents: 16453
diff changeset
    64
  static void add_metaspace_memory_pools();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  static MemoryPool*    get_memory_pool(instanceHandle pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  static MemoryManager* get_memory_manager(instanceHandle mgr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  static const int num_memory_pools() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    return _pools_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  static const int num_memory_managers() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    return _managers_list->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  static MemoryPool* get_memory_pool(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    return _pools_list->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  static MemoryManager* get_memory_manager(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    return _managers_list->at(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  static void track_memory_usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  static void track_code_cache_memory_usage() {
26796
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    86
    // Track memory pool usage of all CodeCache memory pools
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    87
    for (int i = 0; i < _code_heap_pools->length(); ++i) {
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    88
      track_memory_pool_usage(_code_heap_pools->at(i));
666464578742 8015774: Add support for multiple code heaps
thartmann
parents: 22234
diff changeset
    89
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
20407
68e215ce8944 8025996: Track metaspace usage when metaspace is expanded
stefank
parents: 18444
diff changeset
    91
  static void track_metaspace_memory_usage() {
68e215ce8944 8025996: Track metaspace usage when metaspace is expanded
stefank
parents: 18444
diff changeset
    92
    track_memory_pool_usage(_metaspace_pool);
68e215ce8944 8025996: Track metaspace usage when metaspace is expanded
stefank
parents: 18444
diff changeset
    93
  }
68e215ce8944 8025996: Track metaspace usage when metaspace is expanded
stefank
parents: 18444
diff changeset
    94
  static void track_compressed_class_memory_usage() {
68e215ce8944 8025996: Track metaspace usage when metaspace is expanded
stefank
parents: 18444
diff changeset
    95
    track_memory_pool_usage(_compressed_class_pool);
68e215ce8944 8025996: Track metaspace usage when metaspace is expanded
stefank
parents: 18444
diff changeset
    96
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  static void track_memory_pool_usage(MemoryPool* pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47216
diff changeset
    99
  static void gc_begin(GCMemoryManager* manager, bool recordGCBeginTime,
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   100
                       bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   101
                       bool recordPreGCUsage, bool recordPeakUsage);
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47216
diff changeset
   102
  static void gc_end(GCMemoryManager* manager, bool recordPostGCUsage,
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   103
                     bool recordAccumulatedGCTime,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 7397
diff changeset
   104
                     bool recordGCEndTime, bool countCollection,
50635
5d3c5af82654 8195115: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results
phh
parents: 48168
diff changeset
   105
                     GCCause::Cause cause,
5d3c5af82654 8195115: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results
phh
parents: 48168
diff changeset
   106
                     bool allMemoryPoolsAffected);
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   107
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  static void oops_do(OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 32623
diff changeset
   110
  static bool get_verbose() { return log_is_enabled(Info, gc); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  static bool set_verbose(bool verbose);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Create an instance of java/lang/management/MemoryUsage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
class TraceMemoryManagerStats : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
private:
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47216
diff changeset
   119
  GCMemoryManager* _gc_memory_manager;
50635
5d3c5af82654 8195115: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results
phh
parents: 48168
diff changeset
   120
  bool         _allMemoryPoolsAffected;
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   121
  bool         _recordGCBeginTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   122
  bool         _recordPreGCUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   123
  bool         _recordPeakUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   124
  bool         _recordPostGCUsage;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   125
  bool         _recordAccumulatedGCTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   126
  bool         _recordGCEndTime;
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   127
  bool         _countCollection;
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 7397
diff changeset
   128
  GCCause::Cause _cause;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
public:
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   130
  TraceMemoryManagerStats() {}
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47216
diff changeset
   131
  TraceMemoryManagerStats(GCMemoryManager* gc_memory_manager,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 7397
diff changeset
   132
                          GCCause::Cause cause,
50635
5d3c5af82654 8195115: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results
phh
parents: 48168
diff changeset
   133
                          bool allMemoryPoolsAffected = true,
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   134
                          bool recordGCBeginTime = true,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   135
                          bool recordPreGCUsage = true,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   136
                          bool recordPeakUsage = true,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   137
                          bool recordPostGCUsage = true,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   138
                          bool recordAccumulatedGCTime = true,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   139
                          bool recordGCEndTime = true,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   140
                          bool countCollection = true);
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   141
48168
cb5d2d4453d0 8191564: Refactor GC related servicability code into GC specific subclasses
rkennke
parents: 47216
diff changeset
   142
  void initialize(GCMemoryManager* gc_memory_manager,
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents: 7397
diff changeset
   143
                  GCCause::Cause cause,
50635
5d3c5af82654 8195115: G1 Old Gen MemoryPool CollectionUsage.used values don't reflect mixed GC results
phh
parents: 48168
diff changeset
   144
                  bool allMemoryPoolsAffected,
6245
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   145
                  bool recordGCBeginTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   146
                  bool recordPreGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   147
                  bool recordPeakUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   148
                  bool recordPostGCUsage,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   149
                  bool recordAccumulatedGCTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   150
                  bool recordGCEndTime,
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   151
                  bool countCollection);
c37d2cf6de1a 6581734: CMS Old Gen's collection usage is zero after GC which is incorrect
kevinw
parents: 5547
diff changeset
   152
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  ~TraceMemoryManagerStats();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6245
diff changeset
   155
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52200
diff changeset
   156
#endif // SHARE_SERVICES_MEMORYSERVICE_HPP