src/hotspot/share/services/memBaseline.hpp
author zgu
Thu, 08 Feb 2018 13:21:22 -0500
changeset 48884 7e17b00dc245
parent 48874 f09fdaad7321
child 49364 601146c66cad
permissions -rw-r--r--
8196923: [REDO] NMT: Report array class count in NMT summary Summary: Added instance and array class counters in NMT summary report Reviewed-by: minqi, stuefe, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     1
/*
48884
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
     2
 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     4
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     8
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    13
 * accompanied this code).
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    14
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    18
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    21
 * questions.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    22
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    23
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    24
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    25
#ifndef SHARE_VM_SERVICES_MEM_BASELINE_HPP
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    26
#define SHARE_VM_SERVICES_MEM_BASELINE_HPP
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    27
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    28
#if INCLUDE_NMT
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    29
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    30
#include "memory/allocation.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    31
#include "runtime/mutex.hpp"
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    32
#include "services/mallocSiteTable.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    33
#include "services/mallocTracker.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    34
#include "services/nmtCommon.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    35
#include "services/virtualMemoryTracker.hpp"
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    36
#include "utilities/linkedlist.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    37
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    38
typedef LinkedListIterator<MallocSite>                   MallocSiteIterator;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    39
typedef LinkedListIterator<VirtualMemoryAllocationSite>  VirtualMemorySiteIterator;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    40
typedef LinkedListIterator<ReservedMemoryRegion>         VirtualMemoryAllocationIterator;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    41
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    42
/*
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    43
 * Baseline a memory snapshot
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    44
 */
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    45
class MemBaseline VALUE_OBJ_CLASS_SPEC {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    46
 public:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    47
  enum BaselineThreshold {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    48
    SIZE_THRESHOLD = K        // Only allocation size over this threshold will be baselined.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    49
  };
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    50
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    51
  enum BaselineType {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    52
    Not_baselined,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    53
    Summary_baselined,
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    54
    Detail_baselined
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    55
  };
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    56
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    57
  enum SortingOrder {
46711
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
    58
    by_address,      // by memory address
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
    59
    by_size,         // by memory size
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
    60
    by_site,         // by call site where the memory is allocated from
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
    61
    by_site_and_type // by call site and memory type
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    62
  };
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    63
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    64
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    65
  // Summary information
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    66
  MallocMemorySnapshot   _malloc_memory_snapshot;
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    67
  VirtualMemorySnapshot  _virtual_memory_snapshot;
47553
5d20359dd938 8186770: NMT: Report metadata information in NMT summary
zgu
parents: 47216
diff changeset
    68
  MetaspaceSnapshot      _metaspace_snapshot;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    69
48884
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    70
  size_t                 _instance_class_count;
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    71
  size_t                 _array_class_count;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    72
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    73
  // Allocation sites information
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    74
  // Malloc allocation sites
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    75
  LinkedListImpl<MallocSite>                  _malloc_sites;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    76
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    77
  // All virtual memory allocations
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    78
  LinkedListImpl<ReservedMemoryRegion>        _virtual_memory_allocations;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    79
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    80
  // Virtual memory allocations by allocation sites, always in by_address
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    81
  // order
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    82
  LinkedListImpl<VirtualMemoryAllocationSite> _virtual_memory_sites;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    83
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    84
  SortingOrder         _malloc_sites_order;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    85
  SortingOrder         _virtual_memory_sites_order;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    86
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    87
  BaselineType         _baseline_type;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    88
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    89
 public:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    90
  // create a memory baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    91
  MemBaseline():
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    92
    _baseline_type(Not_baselined),
48884
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
    93
    _instance_class_count(0), _array_class_count(0) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    94
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    95
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    96
  bool baseline(bool summaryOnly = true);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    97
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    98
  BaselineType baseline_type() const { return _baseline_type; }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    99
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   100
  MallocMemorySnapshot* malloc_memory_snapshot() {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   101
    return &_malloc_memory_snapshot;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   102
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   103
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   104
  VirtualMemorySnapshot* virtual_memory_snapshot() {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   105
    return &_virtual_memory_snapshot;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   106
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   107
47553
5d20359dd938 8186770: NMT: Report metadata information in NMT summary
zgu
parents: 47216
diff changeset
   108
  MetaspaceSnapshot* metaspace_snapshot() {
5d20359dd938 8186770: NMT: Report metadata information in NMT summary
zgu
parents: 47216
diff changeset
   109
    return &_metaspace_snapshot;
5d20359dd938 8186770: NMT: Report metadata information in NMT summary
zgu
parents: 47216
diff changeset
   110
  }
5d20359dd938 8186770: NMT: Report metadata information in NMT summary
zgu
parents: 47216
diff changeset
   111
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   112
  MallocSiteIterator malloc_sites(SortingOrder order);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   113
  VirtualMemorySiteIterator virtual_memory_sites(SortingOrder order);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   114
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   115
  // Virtual memory allocation iterator always returns in virtual memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   116
  // base address order.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   117
  VirtualMemoryAllocationIterator virtual_memory_allocations() {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   118
    assert(!_virtual_memory_allocations.is_empty(), "Not detail baseline");
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   119
    return VirtualMemoryAllocationIterator(_virtual_memory_allocations.head());
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   120
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   121
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   122
  // Total reserved memory = total malloc'd memory + total reserved virtual
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   123
  // memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   124
  size_t total_reserved_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   125
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   126
    size_t amount = _malloc_memory_snapshot.total() +
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   127
           _virtual_memory_snapshot.total_reserved();
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   128
    return amount;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   129
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   130
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   131
  // Total committed memory = total malloc'd memory + total committed
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   132
  // virtual memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   133
  size_t total_committed_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   134
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   135
    size_t amount = _malloc_memory_snapshot.total() +
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   136
           _virtual_memory_snapshot.total_committed();
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   137
    return amount;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   138
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   139
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   140
  size_t total_arena_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   141
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   142
    return _malloc_memory_snapshot.total_arena();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   143
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   144
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   145
  size_t malloc_tracking_overhead() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   146
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   147
    MemBaseline* bl = const_cast<MemBaseline*>(this);
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   148
    return bl->_malloc_memory_snapshot.malloc_overhead()->size();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   149
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   150
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   151
  MallocMemory* malloc_memory(MEMFLAGS flag) {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   152
    assert(baseline_type() != Not_baselined, "Not yet baselined");
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   153
    return _malloc_memory_snapshot.by_type(flag);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   154
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   155
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   156
  VirtualMemory* virtual_memory(MEMFLAGS flag) {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   157
    assert(baseline_type() != Not_baselined, "Not yet baselined");
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   158
    return _virtual_memory_snapshot.by_type(flag);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   159
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   160
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   161
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   162
  size_t class_count() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   163
    assert(baseline_type() != Not_baselined, "Not yet baselined");
48884
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   164
    return _instance_class_count + _array_class_count;
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   165
  }
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   166
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   167
  size_t instance_class_count() const {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   168
    assert(baseline_type() != Not_baselined, "Not yet baselined");
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   169
    return _instance_class_count;
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   170
  }
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   171
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   172
  size_t array_class_count() const {
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   173
    assert(baseline_type() != Not_baselined, "Not yet baselined");
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   174
    return _array_class_count;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   175
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   176
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   177
  size_t thread_count() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   178
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   179
    return _malloc_memory_snapshot.thread_count();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   180
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   181
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   182
  // reset the baseline for reuse
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   183
  void reset() {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   184
    _baseline_type = Not_baselined;
27162
0a4a7276949b 8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
coleenp
parents: 26288
diff changeset
   185
    // _malloc_memory_snapshot and _virtual_memory_snapshot are copied over.
48884
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   186
    _instance_class_count  = 0;
7e17b00dc245 8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents: 48874
diff changeset
   187
    _array_class_count = 0;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   188
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   189
    _malloc_sites.clear();
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   190
    _virtual_memory_sites.clear();
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   191
    _virtual_memory_allocations.clear();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   192
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   193
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   194
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   195
  // Baseline summary information
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   196
  bool baseline_summary();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   197
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   198
  // Baseline allocation sites (detail tracking only)
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   199
  bool baseline_allocation_sites();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   200
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   201
  // Aggregate virtual memory allocation by allocation sites
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   202
  bool aggregate_virtual_memory_allocation_sites();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   203
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   204
  // Sorting allocation sites in different orders
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   205
  // Sort allocation sites in size order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   206
  void malloc_sites_to_size_order();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   207
  // Sort allocation sites in call site address order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   208
  void malloc_sites_to_allocation_site_order();
46711
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
   209
  // Sort allocation sites in call site address and memory type order
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
   210
  void malloc_sites_to_allocation_site_and_type_order();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   211
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   212
  // Sort allocation sites in reserved size order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   213
  void virtual_memory_sites_to_size_order();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   214
  // Sort allocation sites in call site address order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   215
  void virtual_memory_sites_to_reservation_site_order();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   216
};
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   217
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   218
#endif // INCLUDE_NMT
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   219
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   220
#endif // SHARE_VM_SERVICES_MEM_BASELINE_HPP