src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58348 c29e49148be7
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     1
/*
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     4
 *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    10
 *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    15
 * accompanied this code).
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    16
 *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    20
 *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    23
 * questions.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    24
 */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    25
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    26
package com.sun.management;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    27
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    28
import java.util.Map;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    29
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    30
/**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    31
 * Platform-specific management interface for the thread system
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    32
 * of the Java virtual machine.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    33
 * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    34
 * This platform extension is only available to a thread
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    35
 * implementation that supports this extension.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    36
 *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    37
 * @author  Paul Hohensee
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    38
 * @since   6u25
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    39
 */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    40
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    41
public interface ThreadMXBean extends java.lang.management.ThreadMXBean {
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    42
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    43
     * Returns the total CPU time for each thread whose ID is
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    44
     * in the input array {@code ids} in nanoseconds.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    45
     * The returned values are of nanoseconds precision but
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    46
     * not necessarily nanoseconds accuracy.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    47
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    48
     * This method is equivalent to calling the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    49
     * {@link ThreadMXBean#getThreadCpuTime(long)}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    50
     * method for each thread ID in the input array {@code ids} and setting the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    51
     * returned value in the corresponding element of the returned array.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    52
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    53
     * @param ids an array of thread IDs.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    54
     * @return an array of long values, each of which is the amount of CPU
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    55
     * time the thread whose ID is in the corresponding element of the input
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    56
     * array of IDs has used,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    57
     * if the thread of a specified ID exists, the thread is alive,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    58
     * and CPU time measurement is enabled;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    59
     * {@code -1} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    60
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    61
     * @throws NullPointerException if {@code ids} is {@code null}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    62
     * @throws IllegalArgumentException if any element in the input array
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    63
     *         {@code ids} is {@code <=} {@code 0}.
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
    64
     * @throws UnsupportedOperationException if the Java
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    65
     *         virtual machine implementation does not support CPU time
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    66
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    67
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    68
     * @see ThreadMXBean#getThreadCpuTime(long)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    69
     * @see #getThreadUserTime
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    70
     * @see ThreadMXBean#isThreadCpuTimeSupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    71
     * @see ThreadMXBean#isThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    72
     * @see ThreadMXBean#setThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    73
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    74
    public long[] getThreadCpuTime(long[] ids);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    75
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    76
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    77
     * Returns the CPU time that each thread whose ID is in the input array
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    78
     * {@code ids} has executed in user mode in nanoseconds.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    79
     * The returned values are of nanoseconds precision but
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    80
     * not necessarily nanoseconds accuracy.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    81
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    82
     * This method is equivalent to calling the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    83
     * {@link ThreadMXBean#getThreadUserTime(long)}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    84
     * method for each thread ID in the input array {@code ids} and setting the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    85
     * returned value in the corresponding element of the returned array.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    86
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    87
     * @param ids an array of thread IDs.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    88
     * @return an array of long values, each of which is the amount of user
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    89
     * mode CPU time the thread whose ID is in the corresponding element of
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    90
     * the input array of IDs has used,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    91
     * if the thread of a specified ID exists, the thread is alive,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    92
     * and CPU time measurement is enabled;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    93
     * {@code -1} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    94
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    95
     * @throws NullPointerException if {@code ids} is {@code null}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    96
     * @throws IllegalArgumentException if any element in the input array
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    97
     *         {@code ids} is {@code <=} {@code 0}.
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
    98
     * @throws UnsupportedOperationException if the Java
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    99
     *         virtual machine implementation does not support CPU time
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   100
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   101
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   102
     * @see ThreadMXBean#getThreadUserTime(long)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   103
     * @see #getThreadCpuTime
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   104
     * @see ThreadMXBean#isThreadCpuTimeSupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   105
     * @see ThreadMXBean#isThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   106
     * @see ThreadMXBean#setThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   107
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   108
    public long[] getThreadUserTime(long[] ids);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   109
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   110
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   111
     * Returns an approximation of the total amount of memory, in bytes,
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   112
     * allocated in heap memory for the current thread.
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   113
     * The returned value is an approximation because some Java virtual machine
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   114
     * implementations may use object allocation mechanisms that result in a
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   115
     * delay between the time an object is allocated and the time its size is
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   116
     * recorded.
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   117
     *
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   118
     * <p>
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   119
     * This is a convenience method for local management use and is
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   120
     * equivalent to calling:
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   121
     * <blockquote><pre>
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   122
     *   {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId());
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   123
     * </pre></blockquote>
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   124
     *
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   125
     * @implSpec The default implementation throws
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   126
     * {@code UnsupportedOperationException}.
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   127
     *
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   128
     * @return an approximation of the total memory allocated, in bytes, in
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   129
     * heap memory for the current thread
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   130
     * if thread memory allocation measurement is enabled;
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   131
     * {@code -1} otherwise.
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   132
     *
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   133
     * @throws UnsupportedOperationException if the Java virtual
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   134
     *         machine implementation does not support thread memory allocation
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   135
     *         measurement.
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   136
     *
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   137
     * @see #isThreadAllocatedMemorySupported
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   138
     * @see #isThreadAllocatedMemoryEnabled
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   139
     * @see #setThreadAllocatedMemoryEnabled
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   140
     *
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   141
     * @since 14
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   142
     */
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   143
    public default long getCurrentThreadAllocatedBytes() {
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   144
        throw new UnsupportedOperationException();
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   145
    }
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   146
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   147
    /**
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   148
     * Returns an approximation of the total amount of memory, in bytes,
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   149
     * allocated in heap memory for the thread with the specified ID.
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   150
     * The returned value is an approximation because some Java virtual machine
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   151
     * implementations may use object allocation mechanisms that result in a
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   152
     * delay between the time an object is allocated and the time its size is
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   153
     * recorded.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   154
     * <p>
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   155
     * If the thread with the specified ID is not alive or does not exist,
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   156
     * this method returns {@code -1}. If thread memory allocation measurement
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   157
     * is disabled, this method returns {@code -1}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   158
     * A thread is alive if it has been started and has not yet died.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   159
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   160
     * If thread memory allocation measurement is enabled after the thread has
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   161
     * started, the Java virtual machine implementation may choose any time up
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   162
     * to and including the time that the capability is enabled as the point
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   163
     * where thread memory allocation measurement starts.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   164
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   165
     * @param id the thread ID of a thread
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   166
     * @return an approximation of the total memory allocated, in bytes, in
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   167
     * heap memory for the thread with the specified ID
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   168
     * if the thread with the specified ID exists, the thread is alive,
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   169
     * and thread memory allocation measurement is enabled;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   170
     * {@code -1} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   171
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   172
     * @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}.
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   173
     * @throws UnsupportedOperationException if the Java virtual
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   174
     *         machine implementation does not support thread memory allocation
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   175
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   176
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   177
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   178
     * @see #isThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   179
     * @see #setThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   180
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   181
    public long getThreadAllocatedBytes(long id);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   182
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   183
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   184
     * Returns an approximation of the total amount of memory, in bytes,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   185
     * allocated in heap memory for each thread whose ID is in the input
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   186
     * array {@code ids}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   187
     * The returned values are approximations because some Java virtual machine
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   188
     * implementations may use object allocation mechanisms that result in a
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   189
     * delay between the time an object is allocated and the time its size is
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   190
     * recorded.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   191
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   192
     * This method is equivalent to calling the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   193
     * {@link #getThreadAllocatedBytes(long)}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   194
     * method for each thread ID in the input array {@code ids} and setting the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   195
     * returned value in the corresponding element of the returned array.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   196
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   197
     * @param ids an array of thread IDs.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   198
     * @return an array of long values, each of which is an approximation of
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   199
     * the total memory allocated, in bytes, in heap memory for the thread
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   200
     * whose ID is in the corresponding element of the input array of IDs.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   201
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   202
     * @throws NullPointerException if {@code ids} is {@code null}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   203
     * @throws IllegalArgumentException if any element in the input array
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   204
     *         {@code ids} is {@code <=} {@code 0}.
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   205
     * @throws UnsupportedOperationException if the Java virtual
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   206
     *         machine implementation does not support thread memory allocation
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   207
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   208
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   209
     * @see #getThreadAllocatedBytes(long)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   210
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   211
     * @see #isThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   212
     * @see #setThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   213
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   214
    public long[] getThreadAllocatedBytes(long[] ids);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   215
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   216
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   217
     * Tests if the Java virtual machine implementation supports thread memory
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   218
     * allocation measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   219
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   220
     * @return
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   221
     *   {@code true}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   222
     *     if the Java virtual machine implementation supports thread memory
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   223
     *     allocation measurement;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   224
     *   {@code false} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   225
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   226
    public boolean isThreadAllocatedMemorySupported();
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   227
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   228
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   229
     * Tests if thread memory allocation measurement is enabled.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   230
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   231
     * @return {@code true} if thread memory allocation measurement is enabled;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   232
     *         {@code false} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   233
     *
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   234
     * @throws UnsupportedOperationException if the Java virtual
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   235
     *         machine does not support thread memory allocation measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   236
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   237
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   238
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   239
    public boolean isThreadAllocatedMemoryEnabled();
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   240
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   241
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   242
     * Enables or disables thread memory allocation measurement.  The default
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   243
     * is platform dependent.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   244
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   245
     * @param enable {@code true} to enable;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   246
     *               {@code false} to disable.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   247
     *
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   248
     * @throws UnsupportedOperationException if the Java virtual
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   249
     *         machine does not support thread memory allocation measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   250
     *
58348
c29e49148be7 8231209: [REDO] ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents: 58223
diff changeset
   251
     * @throws SecurityException if a security manager
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   252
     *         exists and the caller does not have
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   253
     *         ManagementPermission("control").
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   254
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   255
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   256
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   257
    public void setThreadAllocatedMemoryEnabled(boolean enable);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   258
}