author | dcubed |
Wed, 18 Sep 2019 20:49:13 -0400 | |
changeset 58223 | 778fc2dcbdaa |
parent 58208 | 0f3c23c374a4 |
child 58348 | c29e49148be7 |
permissions | -rw-r--r-- |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
1 |
/* |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
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 |
|
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}. |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
64 |
* @throws java.lang.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}. |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
98 |
* @throws java.lang.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, |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
112 |
* allocated in heap memory for the thread of the specified ID. |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
113 |
* 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
|
114 |
* 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
|
115 |
* 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
|
116 |
* recorded. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
117 |
* <p> |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
118 |
* If the thread of 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
|
119 |
* 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
|
120 |
* is disabled, this method returns {@code -1}. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
121 |
* 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
|
122 |
* <p> |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
123 |
* 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
|
124 |
* 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
|
125 |
* 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
|
126 |
* where thread memory allocation measurement starts. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
127 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
128 |
* @param id the thread ID of a thread |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
129 |
* @return an approximation of the total memory allocated, in bytes, in |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
130 |
* heap memory for a thread of the specified ID |
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
131 |
* if the thread of the specified ID exists, the thread is alive, |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
132 |
* and thread memory allocation measurement is enabled; |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
133 |
* {@code -1} otherwise. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
134 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
135 |
* @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}. |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
136 |
* @throws java.lang.UnsupportedOperationException if the Java virtual |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
137 |
* machine implementation does not support thread memory allocation |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
138 |
* measurement. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
139 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
140 |
* @see #isThreadAllocatedMemorySupported |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
141 |
* @see #isThreadAllocatedMemoryEnabled |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
142 |
* @see #setThreadAllocatedMemoryEnabled |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
143 |
*/ |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
144 |
public long getThreadAllocatedBytes(long id); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
145 |
|
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 |
* 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
|
148 |
* 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
|
149 |
* array {@code ids}. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
150 |
* 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
|
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> |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
155 |
* This method is equivalent to calling the |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
156 |
* {@link #getThreadAllocatedBytes(long)} |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
157 |
* 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
|
158 |
* 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
|
159 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
160 |
* @param ids an array of thread IDs. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
161 |
* @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
|
162 |
* 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
|
163 |
* 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
|
164 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
165 |
* @throws NullPointerException if {@code ids} is {@code null} |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
166 |
* @throws IllegalArgumentException if any element in the input array |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
167 |
* {@code ids} is {@code <=} {@code 0}. |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
168 |
* @throws java.lang.UnsupportedOperationException if the Java virtual |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
169 |
* machine implementation does not support thread memory allocation |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
170 |
* measurement. |
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 |
* @see #getThreadAllocatedBytes(long) |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
173 |
* @see #isThreadAllocatedMemorySupported |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
174 |
* @see #isThreadAllocatedMemoryEnabled |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
175 |
* @see #setThreadAllocatedMemoryEnabled |
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 |
public long[] getThreadAllocatedBytes(long[] ids); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
178 |
|
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 |
* 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
|
181 |
* allocation measurement. |
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 |
* @return |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
184 |
* {@code true} |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
185 |
* if the Java virtual machine implementation supports thread memory |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
186 |
* allocation measurement; |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
187 |
* {@code false} otherwise. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
188 |
*/ |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
189 |
public boolean isThreadAllocatedMemorySupported(); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
190 |
|
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 |
* Tests if thread memory allocation measurement is enabled. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
193 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
194 |
* @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
|
195 |
* {@code false} otherwise. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
196 |
* |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
197 |
* @throws java.lang.UnsupportedOperationException if the Java virtual |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
198 |
* machine does not support thread memory allocation measurement. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
199 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
200 |
* @see #isThreadAllocatedMemorySupported |
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 |
public boolean isThreadAllocatedMemoryEnabled(); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
203 |
|
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 |
* Enables or disables thread memory allocation measurement. The default |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
206 |
* is platform dependent. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
207 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
208 |
* @param enable {@code true} to enable; |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
209 |
* {@code false} to disable. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
210 |
* |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
211 |
* @throws java.lang.UnsupportedOperationException if the Java virtual |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
212 |
* machine does not support thread memory allocation measurement. |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
213 |
* |
58223
778fc2dcbdaa
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
dcubed
parents:
58208
diff
changeset
|
214 |
* @throws java.lang.SecurityException if a security manager |
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
215 |
* exists and the caller does not have |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
216 |
* ManagementPermission("control"). |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
217 |
* |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
218 |
* @see #isThreadAllocatedMemorySupported |
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 |
public void setThreadAllocatedMemoryEnabled(boolean enable); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
diff
changeset
|
221 |
} |