jdk/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java
author sjiang
Fri, 17 Apr 2015 09:40:02 +0200
changeset 30355 e37c7eba132f
parent 25859 jdk/src/java.management/share/classes/com/sun/management/ThreadMXBean.java@3317bb8137f4
child 34894 3248b89d1921
permissions -rw-r--r--
8042901: Allow com.sun.management to be in a different module to java.lang.management Reviewed-by: mchung, dfuchs, erikj, jbachorik
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
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20742
diff changeset
     2
 * Copyright (c) 2011, 2013, 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
20742
4ae78e8060d6 8008662: Add @jdk.Exported to JDK-specific/exported APIs
alanb
parents: 8001
diff changeset
    41
@jdk.Exported
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    42
public interface ThreadMXBean extends java.lang.management.ThreadMXBean {
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    43
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    44
     * 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
    45
     * in the input array {@code ids} in nanoseconds.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    46
     * The returned values are of nanoseconds precision but
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    47
     * not necessarily nanoseconds accuracy.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    48
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    49
     * This method is equivalent to calling the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    50
     * {@link ThreadMXBean#getThreadCpuTime(long)}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    51
     * 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
    52
     * 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
    53
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    54
     * @param ids an array of thread IDs.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    55
     * @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
    56
     * 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
    57
     * array of IDs has used,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    58
     * 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
    59
     * and CPU time measurement is enabled;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    60
     * {@code -1} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    61
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    62
     * @throws NullPointerException if {@code ids} is {@code null}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    63
     * @throws IllegalArgumentException if any element in the input array
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    64
     *         {@code ids} is {@code <=} {@code 0}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    65
     * @throws java.lang.UnsupportedOperationException if the Java
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    66
     *         virtual machine implementation does not support CPU time
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    67
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    68
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    69
     * @see ThreadMXBean#getThreadCpuTime(long)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    70
     * @see #getThreadUserTime
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    71
     * @see ThreadMXBean#isThreadCpuTimeSupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    72
     * @see ThreadMXBean#isThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    73
     * @see ThreadMXBean#setThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    74
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    75
    public long[] getThreadCpuTime(long[] ids);
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
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    78
     * 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
    79
     * {@code ids} has executed in user mode in nanoseconds.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    80
     * The returned values are of nanoseconds precision but
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    81
     * not necessarily nanoseconds accuracy.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    82
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    83
     * This method is equivalent to calling the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    84
     * {@link ThreadMXBean#getThreadUserTime(long)}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    85
     * 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
    86
     * 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
    87
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    88
     * @param ids an array of thread IDs.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    89
     * @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
    90
     * 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
    91
     * the input array of IDs has used,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    92
     * 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
    93
     * and CPU time measurement is enabled;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    94
     * {@code -1} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    95
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    96
     * @throws NullPointerException if {@code ids} is {@code null}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    97
     * @throws IllegalArgumentException if any element in the input array
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    98
     *         {@code ids} is {@code <=} {@code 0}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
    99
     * @throws java.lang.UnsupportedOperationException if the Java
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   100
     *         virtual machine implementation does not support CPU time
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   101
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   102
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   103
     * @see ThreadMXBean#getThreadUserTime(long)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   104
     * @see #getThreadCpuTime
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   105
     * @see ThreadMXBean#isThreadCpuTimeSupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   106
     * @see ThreadMXBean#isThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   107
     * @see ThreadMXBean#setThreadCpuTimeEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   108
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   109
    public long[] getThreadUserTime(long[] ids);
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
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   112
     * 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
   113
     * allocated in heap memory for the thread of the specified ID.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   114
     * 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
   115
     * 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
   116
     * 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
   117
     * recorded.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   118
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   119
     * If the thread of the specified ID is not alive or does not exist,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   120
     * 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
   121
     * is disabled, this method returns {@code -1}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   122
     * 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
   123
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   124
     * 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
   125
     * 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
   126
     * 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
   127
     * where thread memory allocation measurement starts.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   128
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   129
     * @param id the thread ID of a thread
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   130
     * @return an approximation of the total memory allocated, in bytes, in
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   131
     * heap memory for a thread of the specified ID
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   132
     * if the thread of the specified ID exists, the thread is alive,
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   133
     * and thread memory allocation measurement is enabled;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   134
     * {@code -1} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   135
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   136
     * @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   137
     * @throws java.lang.UnsupportedOperationException if the Java virtual
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   138
     *         machine implementation does not support thread memory allocation
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   139
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   140
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   141
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   142
     * @see #isThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   143
     * @see #setThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   144
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   145
    public long getThreadAllocatedBytes(long id);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   146
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   147
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   148
     * 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
   149
     * 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
   150
     * array {@code ids}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   151
     * 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
   152
     * 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
   153
     * 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
   154
     * recorded.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   155
     * <p>
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   156
     * This method is equivalent to calling the
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   157
     * {@link #getThreadAllocatedBytes(long)}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   158
     * 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
   159
     * 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
   160
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   161
     * @param ids an array of thread IDs.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   162
     * @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
   163
     * 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
   164
     * 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
   165
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   166
     * @throws NullPointerException if {@code ids} is {@code null}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   167
     * @throws IllegalArgumentException if any element in the input array
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   168
     *         {@code ids} is {@code <=} {@code 0}.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   169
     * @throws java.lang.UnsupportedOperationException if the Java virtual
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   170
     *         machine implementation does not support thread memory allocation
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   171
     *         measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   172
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   173
     * @see #getThreadAllocatedBytes(long)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   174
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   175
     * @see #isThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   176
     * @see #setThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   177
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   178
    public long[] getThreadAllocatedBytes(long[] ids);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   179
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
     * 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
   182
     * allocation measurement.
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
     * @return
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   185
     *   {@code true}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   186
     *     if the Java virtual machine implementation supports thread memory
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   187
     *     allocation measurement;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   188
     *   {@code false} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   189
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   190
    public boolean isThreadAllocatedMemorySupported();
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   191
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   192
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   193
     * Tests if thread memory allocation measurement is enabled.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   194
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   195
     * @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
   196
     *         {@code false} otherwise.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   197
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   198
     * @throws java.lang.UnsupportedOperationException if the Java virtual
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   199
     *         machine does not support thread memory allocation measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   200
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   201
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   202
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   203
    public boolean isThreadAllocatedMemoryEnabled();
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   204
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   205
    /**
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   206
     * Enables or disables thread memory allocation measurement.  The default
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   207
     * is platform dependent.
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
     * @param enable {@code true} to enable;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   210
     *               {@code false} to disable.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   211
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   212
     * @throws java.lang.UnsupportedOperationException if the Java virtual
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   213
     *         machine does not support thread memory allocation measurement.
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   214
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   215
     * @throws java.lang.SecurityException if a security manager
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   216
     *         exists and the caller does not have
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   217
     *         ManagementPermission("control").
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   218
     *
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   219
     * @see #isThreadAllocatedMemorySupported
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   220
     */
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   221
    public void setThreadAllocatedMemoryEnabled(boolean enable);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff changeset
   222
}