hotspot/src/share/vm/services/memBaseline.hpp
author coleenp
Fri, 10 Oct 2014 19:36:12 +0000
changeset 27162 0a4a7276949b
parent 26288 631bf42cf7c2
child 46711 0ccef2260315
permissions -rw-r--r--
8059100: SIGSEGV VirtualMemoryTracker::remove_released_region Summary: Disallow increasing native memory tracking level Reviewed-by: hseigel, ctornqvi, gtriantafill
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     1
/*
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
     2
 * Copyright (c) 2012, 2014, 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 {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    58
    by_address,   // by memory address
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    59
    by_size,      // by memory size
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    60
    by_site       // by call site where the memory is allocated from
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    61
  };
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    62
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    63
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    64
  // Summary information
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    65
  MallocMemorySnapshot   _malloc_memory_snapshot;
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    66
  VirtualMemorySnapshot  _virtual_memory_snapshot;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    67
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    68
  size_t               _class_count;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    69
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    70
  // Allocation sites information
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    71
  // Malloc allocation sites
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    72
  LinkedListImpl<MallocSite>                  _malloc_sites;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    73
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    74
  // All virtual memory allocations
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    75
  LinkedListImpl<ReservedMemoryRegion>        _virtual_memory_allocations;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    76
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    77
  // Virtual memory allocations by allocation sites, always in by_address
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    78
  // order
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    79
  LinkedListImpl<VirtualMemoryAllocationSite> _virtual_memory_sites;
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    80
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    81
  SortingOrder         _malloc_sites_order;
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    82
  SortingOrder         _virtual_memory_sites_order;
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
  BaselineType         _baseline_type;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    85
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    86
 public:
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    87
  // create a memory baseline
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    88
  MemBaseline():
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    89
    _baseline_type(Not_baselined),
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    90
    _class_count(0) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    91
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    92
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    93
  bool baseline(bool summaryOnly = true);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    94
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
    95
  BaselineType baseline_type() const { return _baseline_type; }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    96
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    97
  MallocMemorySnapshot* malloc_memory_snapshot() {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
    98
    return &_malloc_memory_snapshot;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    99
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   100
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   101
  VirtualMemorySnapshot* virtual_memory_snapshot() {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   102
    return &_virtual_memory_snapshot;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   103
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   104
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   105
  MallocSiteIterator malloc_sites(SortingOrder order);
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   106
  VirtualMemorySiteIterator virtual_memory_sites(SortingOrder order);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   107
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   108
  // Virtual memory allocation iterator always returns in virtual memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   109
  // base address order.
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   110
  VirtualMemoryAllocationIterator virtual_memory_allocations() {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   111
    assert(!_virtual_memory_allocations.is_empty(), "Not detail baseline");
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   112
    return VirtualMemoryAllocationIterator(_virtual_memory_allocations.head());
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   113
  }
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
  // Total reserved memory = total malloc'd memory + total reserved virtual
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   116
  // memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   117
  size_t total_reserved_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   118
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   119
    size_t amount = _malloc_memory_snapshot.total() +
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   120
           _virtual_memory_snapshot.total_reserved();
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   121
    return amount;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   122
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   123
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   124
  // Total committed memory = total malloc'd memory + total committed
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   125
  // virtual memory
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   126
  size_t total_committed_memory() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   127
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   128
    size_t amount = _malloc_memory_snapshot.total() +
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   129
           _virtual_memory_snapshot.total_committed();
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   130
    return amount;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   131
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   132
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   133
  size_t total_arena_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
    return _malloc_memory_snapshot.total_arena();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   136
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   137
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   138
  size_t malloc_tracking_overhead() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   139
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   140
    MemBaseline* bl = const_cast<MemBaseline*>(this);
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   141
    return bl->_malloc_memory_snapshot.malloc_overhead()->size();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   142
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   143
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   144
  MallocMemory* malloc_memory(MEMFLAGS flag) {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   145
    assert(baseline_type() != Not_baselined, "Not yet baselined");
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   146
    return _malloc_memory_snapshot.by_type(flag);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   147
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   148
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   149
  VirtualMemory* virtual_memory(MEMFLAGS flag) {
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   150
    assert(baseline_type() != Not_baselined, "Not yet baselined");
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   151
    return _virtual_memory_snapshot.by_type(flag);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   152
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   153
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   154
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   155
  size_t class_count() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   156
    assert(baseline_type() != Not_baselined, "Not yet baselined");
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   157
    return _class_count;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   158
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   159
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   160
  size_t thread_count() const {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   161
    assert(baseline_type() != Not_baselined, "Not yet baselined");
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   162
    return _malloc_memory_snapshot.thread_count();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   163
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   164
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   165
  // reset the baseline for reuse
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   166
  void reset() {
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   167
    _baseline_type = Not_baselined;
27162
0a4a7276949b 8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
coleenp
parents: 26288
diff changeset
   168
    // _malloc_memory_snapshot and _virtual_memory_snapshot are copied over.
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   169
    _class_count  = 0;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   170
26288
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   171
    _malloc_sites.clear();
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   172
    _virtual_memory_sites.clear();
631bf42cf7c2 8054546: NMT2 leaks memory
zgu
parents: 25946
diff changeset
   173
    _virtual_memory_allocations.clear();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   174
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   175
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   176
 private:
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   177
  // Baseline summary information
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   178
  bool baseline_summary();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   179
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   180
  // Baseline allocation sites (detail tracking only)
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   181
  bool baseline_allocation_sites();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   182
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   183
  // Aggregate virtual memory allocation by allocation sites
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   184
  bool aggregate_virtual_memory_allocation_sites();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   185
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   186
  // Sorting allocation sites in different orders
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   187
  // Sort allocation sites in size order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   188
  void malloc_sites_to_size_order();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   189
  // Sort allocation sites in call site address order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   190
  void malloc_sites_to_allocation_site_order();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   191
25946
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   192
  // Sort allocation sites in reserved size order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   193
  void virtual_memory_sites_to_size_order();
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   194
  // Sort allocation sites in call site address order
1572c9f03fb9 8046598: Scalable Native memory tracking development
zgu
parents: 17074
diff changeset
   195
  void virtual_memory_sites_to_reservation_site_order();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   196
};
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
#endif // INCLUDE_NMT
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
#endif // SHARE_VM_SERVICES_MEM_BASELINE_HPP