Clojure Thread Dump
From the department of How Did I Never Learn This in 12+ Years of Clojure? comes today’s tip:
Did you know you can generate a thread dump (+ memory usage information) from a Clojure REPL with a single keystroke? I sure didn’t.
Press C-\
to make it happen:
$ clojure
Clojure 1.11.1
user=> [C-\]
Full thread dump OpenJDK 64-Bit Server VM (20.0.1 mixed mode, sharing):
Threads class SMR info:
_java_thread_list=0x0000600001019a40, length=12, elements={
0x00007f91b7808a00, 0x00007f91b7012000, 0x00007f919580a400, 0x00007f91b78b5800,
0x00007f91b580e200, 0x00007f91b5811600, 0x00007f919680a400, 0x00007f919580aa00,
0x00007f919581de00, 0x00007f919581e400, 0x00007f91b680a800, 0x00007f91b683e200
}
"main" #1 [10243] prio=5 os_prio=31 cpu=511.55ms elapsed=1.48s tid=0x00007f91b7808a00 nid=10243 runnable [0x00007000085c5000]
java.lang.Thread.State: RUNNABLE
at java.io.FileInputStream.readBytes(java.base@20.0.1/Native Method)
at java.io.FileInputStream.read(java.base@20.0.1/FileInputStream.java:293)
at java.io.BufferedInputStream.read1(java.base@20.0.1/BufferedInputStream.java:311)
at java.io.BufferedInputStream.implRead(java.base@20.0.1/BufferedInputStream.java:386)
at java.io.BufferedInputStream.read(java.base@20.0.1/BufferedInputStream.java:365)
at sun.nio.cs.StreamDecoder.readBytes(java.base@20.0.1/StreamDecoder.java:333)
at sun.nio.cs.StreamDecoder.implRead(java.base@20.0.1/StreamDecoder.java:376)
at sun.nio.cs.StreamDecoder.lockedRead(java.base@20.0.1/StreamDecoder.java:219)
at sun.nio.cs.StreamDecoder.read(java.base@20.0.1/StreamDecoder.java:173)
at java.io.InputStreamReader.read(java.base@20.0.1/InputStreamReader.java:189)
at java.io.BufferedReader.fill(java.base@20.0.1/BufferedReader.java:161)
at java.io.BufferedReader.implRead(java.base@20.0.1/BufferedReader.java:197)
at java.io.BufferedReader.read(java.base@20.0.1/BufferedReader.java:188)
- locked <0x000000061e4c7cf0> (a java.io.InputStreamReader)
at java.io.LineNumberReader.read(java.base@20.0.1/LineNumberReader.java:138)
- locked <0x000000061e4c7cf0> (a java.io.InputStreamReader)
[...]
"VM Periodic Task Thread" os_prio=31 cpu=0.86ms elapsed=1.47s tid=0x00007f9195707dd0 nid=29443 waiting on condition
JNI global refs: 9, weak refs: 0
Heap
garbage-first heap total 532480K, used 25492K [0x0000000600000000, 0x0000000800000000)
region size 4096K, 6 young (24576K), 1 survivors (4096K)
Metaspace used 11242K, committed 11392K, reserved 1114112K
class space used 2590K, committed 2688K, reserved 1048576K
Really it’s just Java functionality (that I never knew existed), but that’s going to come in really handy one day.