equal
deleted
inserted
replaced
120 * equivalent to calling: |
120 * equivalent to calling: |
121 * <blockquote><pre> |
121 * <blockquote><pre> |
122 * {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId()); |
122 * {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId()); |
123 * </pre></blockquote> |
123 * </pre></blockquote> |
124 * |
124 * |
125 * @implSpec The default implementation throws |
|
126 * {@code UnsupportedOperationException}. |
|
127 * |
|
128 * @return an approximation of the total memory allocated, in bytes, in |
125 * @return an approximation of the total memory allocated, in bytes, in |
129 * heap memory for the current thread |
126 * heap memory for the current thread |
130 * if thread memory allocation measurement is enabled; |
127 * if thread memory allocation measurement is enabled; |
131 * {@code -1} otherwise. |
128 * {@code -1} otherwise. |
132 * |
129 * |
139 * @see #setThreadAllocatedMemoryEnabled |
136 * @see #setThreadAllocatedMemoryEnabled |
140 * |
137 * |
141 * @since 14 |
138 * @since 14 |
142 */ |
139 */ |
143 public default long getCurrentThreadAllocatedBytes() { |
140 public default long getCurrentThreadAllocatedBytes() { |
144 throw new UnsupportedOperationException(); |
141 return getThreadAllocatedBytes(Thread.currentThread().getId()); |
145 } |
142 } |
146 |
143 |
147 /** |
144 /** |
148 * Returns an approximation of the total amount of memory, in bytes, |
145 * Returns an approximation of the total amount of memory, in bytes, |
149 * allocated in heap memory for the thread with the specified ID. |
146 * allocated in heap memory for the thread with the specified ID. |