File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/main/java/org/truffleruby/core Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 201
201
"requires" : [
202
202
"java.logging" ,
203
203
"java.management" ,
204
+ "jdk.management" ,
204
205
"jdk.unsupported" , # sun.misc.Signal
205
206
],
206
207
"dependencies" : [
Original file line number Diff line number Diff line change 39
39
package org .truffleruby .core ;
40
40
41
41
import java .io .IOException ;
42
+ import java .lang .management .ManagementFactory ;
42
43
import java .nio .file .NoSuchFileException ;
43
44
import java .util .Set ;
44
45
import java .util .logging .Level ;
45
46
46
47
import com .oracle .truffle .api .strings .TruffleString ;
48
+ import com .sun .management .ThreadMXBean ;
47
49
import org .truffleruby .RubyLanguage ;
48
50
import org .truffleruby .builtins .CoreMethod ;
49
51
import org .truffleruby .builtins .CoreMethodArrayArgumentsNode ;
@@ -273,4 +275,19 @@ protected int availableProcessors() {
273
275
274
276
}
275
277
278
+ @ CoreMethod (names = "allocated_bytes_of_current_thread" , onSingleton = true )
279
+ public abstract static class AllocatedBytesNode extends CoreMethodArrayArgumentsNode {
280
+ private static ThreadMXBean bean ;
281
+
282
+ @ TruffleBoundary
283
+ @ Specialization
284
+ protected static long allocatedBytes () {
285
+ if (bean == null ) {
286
+ bean = (ThreadMXBean ) ManagementFactory .getThreadMXBean ();
287
+ bean .setThreadAllocatedMemoryEnabled (true );
288
+ }
289
+
290
+ return bean .getCurrentThreadAllocatedBytes ();
291
+ }
292
+ }
276
293
}
You can’t perform that action at this time.
0 commit comments