1 /*
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
92 * and CPU time measurement is enabled;
93 * {@code -1} otherwise.
94 *
95 * @throws NullPointerException if {@code ids} is {@code null}
96 * @throws IllegalArgumentException if any element in the input array
97 * {@code ids} is {@code <=} {@code 0}.
98 * @throws java.lang.UnsupportedOperationException if the Java
99 * virtual machine implementation does not support CPU time
100 * measurement.
101 *
102 * @see ThreadMXBean#getThreadUserTime(long)
103 * @see #getThreadCpuTime
104 * @see ThreadMXBean#isThreadCpuTimeSupported
105 * @see ThreadMXBean#isThreadCpuTimeEnabled
106 * @see ThreadMXBean#setThreadCpuTimeEnabled
107 */
108 public long[] getThreadUserTime(long[] ids);
109
110 /**
111 * Returns an approximation of the total amount of memory, in bytes,
112 * allocated in heap memory for the thread of the specified ID.
113 * The returned value is an approximation because some Java virtual machine
114 * implementations may use object allocation mechanisms that result in a
115 * delay between the time an object is allocated and the time its size is
116 * recorded.
117 * <p>
118 * If the thread of the specified ID is not alive or does not exist,
119 * this method returns {@code -1}. If thread memory allocation measurement
120 * is disabled, this method returns {@code -1}.
121 * A thread is alive if it has been started and has not yet died.
122 * <p>
123 * If thread memory allocation measurement is enabled after the thread has
124 * started, the Java virtual machine implementation may choose any time up
125 * to and including the time that the capability is enabled as the point
126 * where thread memory allocation measurement starts.
127 *
128 * @param id the thread ID of a thread
129 * @return an approximation of the total memory allocated, in bytes, in
130 * heap memory for a thread of the specified ID
131 * if the thread of the specified ID exists, the thread is alive,
132 * and thread memory allocation measurement is enabled;
133 * {@code -1} otherwise.
134 *
135 * @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}.
136 * @throws java.lang.UnsupportedOperationException if the Java virtual
137 * machine implementation does not support thread memory allocation
138 * measurement.
139 *
140 * @see #isThreadAllocatedMemorySupported
141 * @see #isThreadAllocatedMemoryEnabled
142 * @see #setThreadAllocatedMemoryEnabled
143 */
144 public long getThreadAllocatedBytes(long id);
145
146 /**
147 * Returns an approximation of the total amount of memory, in bytes,
148 * allocated in heap memory for each thread whose ID is in the input
149 * array {@code ids}.
150 * The returned values are approximations because some Java virtual machine
151 * implementations may use object allocation mechanisms that result in a
|
1 /*
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
92 * and CPU time measurement is enabled;
93 * {@code -1} otherwise.
94 *
95 * @throws NullPointerException if {@code ids} is {@code null}
96 * @throws IllegalArgumentException if any element in the input array
97 * {@code ids} is {@code <=} {@code 0}.
98 * @throws java.lang.UnsupportedOperationException if the Java
99 * virtual machine implementation does not support CPU time
100 * measurement.
101 *
102 * @see ThreadMXBean#getThreadUserTime(long)
103 * @see #getThreadCpuTime
104 * @see ThreadMXBean#isThreadCpuTimeSupported
105 * @see ThreadMXBean#isThreadCpuTimeEnabled
106 * @see ThreadMXBean#setThreadCpuTimeEnabled
107 */
108 public long[] getThreadUserTime(long[] ids);
109
110 /**
111 * Returns an approximation of the total amount of memory, in bytes,
112 * allocated in heap memory for the current thread.
113 * The returned value is an approximation because some Java virtual machine
114 * implementations may use object allocation mechanisms that result in a
115 * delay between the time an object is allocated and the time its size is
116 * recorded.
117 *
118 * <p>
119 * This is a convenience method for local management use and is
120 * equivalent to calling:
121 * <blockquote><pre>
122 * {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId());
123 * </pre></blockquote>
124 *
125 * @return an approximation of the total memory allocated, in bytes, in
126 * heap memory for the current thread
127 * if thread memory allocation measurement is enabled;
128 * {@code -1} otherwise.
129 *
130 * @throws java.lang.UnsupportedOperationException if the Java virtual
131 * machine implementation does not support thread memory allocation
132 * measurement.
133 *
134 * @see #isThreadAllocatedMemorySupported
135 * @see #isThreadAllocatedMemoryEnabled
136 * @see #setThreadAllocatedMemoryEnabled
137 */
138 public long getCurrentThreadAllocatedBytes();
139
140 /**
141 * Returns an approximation of the total amount of memory, in bytes,
142 * allocated in heap memory for the thread with the specified ID.
143 * The returned value is an approximation because some Java virtual machine
144 * implementations may use object allocation mechanisms that result in a
145 * delay between the time an object is allocated and the time its size is
146 * recorded.
147 * <p>
148 * If the thread with the specified ID is not alive or does not exist,
149 * this method returns {@code -1}. If thread memory allocation measurement
150 * is disabled, this method returns {@code -1}.
151 * A thread is alive if it has been started and has not yet died.
152 * <p>
153 * If thread memory allocation measurement is enabled after the thread has
154 * started, the Java virtual machine implementation may choose any time up
155 * to and including the time that the capability is enabled as the point
156 * where thread memory allocation measurement starts.
157 *
158 * @param id the thread ID of a thread
159 * @return an approximation of the total memory allocated, in bytes, in
160 * heap memory for the thread with the specified ID
161 * if the thread with the specified ID exists, the thread is alive,
162 * and thread memory allocation measurement is enabled;
163 * {@code -1} otherwise.
164 *
165 * @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}.
166 * @throws java.lang.UnsupportedOperationException if the Java virtual
167 * machine implementation does not support thread memory allocation
168 * measurement.
169 *
170 * @see #isThreadAllocatedMemorySupported
171 * @see #isThreadAllocatedMemoryEnabled
172 * @see #setThreadAllocatedMemoryEnabled
173 */
174 public long getThreadAllocatedBytes(long id);
175
176 /**
177 * Returns an approximation of the total amount of memory, in bytes,
178 * allocated in heap memory for each thread whose ID is in the input
179 * array {@code ids}.
180 * The returned values are approximations because some Java virtual machine
181 * implementations may use object allocation mechanisms that result in a
|