src/hotspot/share/services/memBaseline.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46711 hotspot/src/share/vm/services/memBaseline.hpp@0ccef2260315
child 47553 5d20359dd938
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     1
/*
46711
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
     2
 * Copyright (c) 2012, 2017, 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;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    68
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    69
  size_t               _class_count;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    70
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    71
  // Allocation sites information
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    72
  // Malloc allocation sites
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    73
  LinkedListImpl<MallocSite>                  _malloc_sites;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    74
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    75
  // All virtual memory allocations
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    76
  LinkedListImpl<ReservedMemoryRegion>        _virtual_memory_allocations;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    77
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    78
  // Virtual memory allocations by allocation sites, always in by_address
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    79
  // order
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    80
  LinkedListImpl<VirtualMemoryAllocationSite> _virtual_memory_sites;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    81
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    82
  SortingOrder         _malloc_sites_order;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    83
  SortingOrder         _virtual_memory_sites_order;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    84
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    85
  BaselineType         _baseline_type;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    86
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    87
 public:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    88
  // create a memory baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    89
  MemBaseline():
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    90
    _baseline_type(Not_baselined),
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    91
    _class_count(0) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    92
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    93
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    94
  bool baseline(bool summaryOnly = true);
13195
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
  BaselineType baseline_type() const { return _baseline_type; }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    97
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    98
  MallocMemorySnapshot* malloc_memory_snapshot() {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    99
    return &_malloc_memory_snapshot;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   100
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   101
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   102
  VirtualMemorySnapshot* virtual_memory_snapshot() {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   103
    return &_virtual_memory_snapshot;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   104
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   105
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   106
  MallocSiteIterator malloc_sites(SortingOrder order);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   107
  VirtualMemorySiteIterator virtual_memory_sites(SortingOrder order);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   108
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   109
  // Virtual memory allocation iterator always returns in virtual memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   110
  // base address order.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   111
  VirtualMemoryAllocationIterator virtual_memory_allocations() {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   112
    assert(!_virtual_memory_allocations.is_empty(), "Not detail baseline");
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   113
    return VirtualMemoryAllocationIterator(_virtual_memory_allocations.head());
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   114
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   115
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   116
  // Total reserved memory = total malloc'd memory + total reserved virtual
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   117
  // memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   118
  size_t total_reserved_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   119
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   120
    size_t amount = _malloc_memory_snapshot.total() +
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   121
           _virtual_memory_snapshot.total_reserved();
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   122
    return amount;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   123
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   124
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   125
  // Total committed memory = total malloc'd memory + total committed
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   126
  // virtual memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   127
  size_t total_committed_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   128
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   129
    size_t amount = _malloc_memory_snapshot.total() +
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   130
           _virtual_memory_snapshot.total_committed();
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   131
    return amount;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   132
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   133
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   134
  size_t total_arena_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   135
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   136
    return _malloc_memory_snapshot.total_arena();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   137
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   138
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   139
  size_t malloc_tracking_overhead() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   140
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   141
    MemBaseline* bl = const_cast<MemBaseline*>(this);
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   142
    return bl->_malloc_memory_snapshot.malloc_overhead()->size();
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
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   145
  MallocMemory* malloc_memory(MEMFLAGS flag) {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   146
    assert(baseline_type() != Not_baselined, "Not yet baselined");
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   147
    return _malloc_memory_snapshot.by_type(flag);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   148
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   149
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   150
  VirtualMemory* virtual_memory(MEMFLAGS flag) {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   151
    assert(baseline_type() != Not_baselined, "Not yet baselined");
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   152
    return _virtual_memory_snapshot.by_type(flag);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   153
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   154
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   155
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   156
  size_t class_count() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   157
    assert(baseline_type() != Not_baselined, "Not yet baselined");
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   158
    return _class_count;
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
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   161
  size_t thread_count() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   162
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   163
    return _malloc_memory_snapshot.thread_count();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   164
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   165
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   166
  // reset the baseline for reuse
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   167
  void reset() {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   168
    _baseline_type = Not_baselined;
27162
0a4a7276949b 8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
coleenp
parents: 26288
diff changeset
   169
    // _malloc_memory_snapshot and _virtual_memory_snapshot are copied over.
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   170
    _class_count  = 0;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   171
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   172
    _malloc_sites.clear();
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   173
    _virtual_memory_sites.clear();
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   174
    _virtual_memory_allocations.clear();
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
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   178
  // Baseline summary information
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   179
  bool baseline_summary();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   180
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   181
  // Baseline allocation sites (detail tracking only)
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   182
  bool baseline_allocation_sites();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   183
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   184
  // Aggregate virtual memory allocation by allocation sites
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   185
  bool aggregate_virtual_memory_allocation_sites();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   186
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   187
  // Sorting allocation sites in different orders
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   188
  // Sort allocation sites in size order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   189
  void malloc_sites_to_size_order();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   190
  // Sort allocation sites in call site address order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   191
  void malloc_sites_to_allocation_site_order();
46711
0ccef2260315 8184991: NMT detail diff should take memory type into account
zgu
parents: 27162
diff changeset
   192
  // 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
   193
  void malloc_sites_to_allocation_site_and_type_order();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   194
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   195
  // Sort allocation sites in reserved size order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   196
  void virtual_memory_sites_to_size_order();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   197
  // Sort allocation sites in call site address order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   198
  void virtual_memory_sites_to_reservation_site_order();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   199
};
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   200
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   201
#endif // INCLUDE_NMT
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   202
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   203
#endif // SHARE_VM_SERVICES_MEM_BASELINE_HPP