Java JFR view 试图功能
JFR jcmd Java About 6,852 wordsjcmd
jcmd <pid> JFR.view
输出
PS \openjdk-25> jcmd 7856 JFR.view
7856:
JFR.view
Display event data in predefined views
Impact: Medium
Options:
cell-height (Optional) Maximum number of rows in a table cell. (INT, no default value)
maxage (Optional) Length of time for the view to span. (INT followed by
's' for seconds 'm' for minutes or 'h' for hours, default value is 10m)
maxsize (Optional) Maximum size for the view to span in bytes if one of
the following suffixes is not used: 'm' or 'M' for megabytes OR
'g' or 'G' for gigabytes. (STRING, default value is 32MB)
truncate (Optional) How to truncate content that exceeds space in a table cell.
Mode can be 'beginning' or 'end'. (STRING, default value 'end')
verbose (Optional) Displays the query that makes up the view.
(BOOLEAN, default value false)
<view> (Mandatory) Name of the view or event type to display.
See list below for available views. (STRING, no default value)
width (Optional) The width of the view in characters
(INT, default value is 100)
Java virtual machine views:
blocked-by-system-gc gc-concurrent-phases jvm-information
class-modifications gc-configuration longest-compilations
compiler-configuration gc-cpu-time native-memory-committed
compiler-phases gc-parallel-phases native-memory-reserved
compiler-statistics gc-pause-phases safepoints
deoptimizations-by-reason gc-pauses tlabs
deoptimizations-by-site gc-references vm-operations
gc heap-configuration
Environment views:
active-recordings cpu-load native-library-failures
active-settings cpu-load-samples network-utilization
container-configuration cpu-tsc recording
container-cpu-throttling environment-variables system-information
container-cpu-usage events-by-count system-processes
container-io-usage events-by-name system-properties
container-memory-usage jvm-flags
Application views:
allocation-by-class exception-by-site method-timing
allocation-by-site exception-by-type modules
allocation-by-thread exception-count monitor-inflation
class-loaders file-reads-by-path native-methods
contention-by-address file-writes-by-path object-statistics
contention-by-class finalizers pinned-threads
contention-by-site hot-methods socket-reads-by-host
contention-by-thread latencies-by-type socket-writes-by-host
cpu-time-hot-methods longest-class-loading thread-allocation
cpu-time-statistics memory-leaks-by-class thread-count
deprecated-methods-for-removal memory-leaks-by-site thread-cpu-load
exception-by-message method-calls thread-start
The <view> parameter can be an event type name. Use the 'JFR.view types'
to see a list. To display all views, use 'JFR.view all-views'. To display
all events, use 'JFR.view all-events'.
Example usage:
$ jcmd <pid> JFR.view gc
$ jcmd <pid> JFR.view width=160 hot-methods
$ jcmd <pid> JFR.view verbose=true allocation-by-class
$ jcmd <pid> JFR.view contention-by-site
$ jcmd <pid> JFR.view jdk.GarbageCollection
$ jcmd <pid> JFR.view cell-height=5 ThreadStart
$ jcmd <pid> JFR.view truncate=beginning SystemProcess
查看事件类型
jcmd <pid> JFR.view types
输出:括号中表示目前采集到的事件个数。
PS \openjdk-25> jcmd 1240 JFR.view types
1240:
Event Types (number of events):
ActiveRecording (1) JavaMonitorStatistics (1)
ActiveSetting (379) JavaMonitorWait (22)
AllocationRequiringGC JavaThreadStatistics (438)
BooleanFlag (489) LongFlag (137)
BooleanFlagChanged LongFlagChanged
CPUInformation (1) MetaspaceAllocationFailure (3)
CPULoad (438) MetaspaceChunkFreeListSummary (132)
CPUTimeStampCounter (1) MetaspaceGCThreshold (6)
ClassDefine MetaspaceOOM
ClassLoad MetaspaceSummary (66)
ClassLoaderStatistics (3) MethodTiming (4959)
ClassLoadingStatistics (438) MethodTrace
ClassRedefinition (1) ModuleExport
ClassUnload ModuleRequire
CodeCacheConfiguration (1) NativeAgent
CodeCacheFull NativeLibrary (48)
CodeCacheStatistics (1) NativeLibraryLoad (5)
Compilation NativeLibraryUnload
CompilationFailure NativeMemoryUsage
CompilerConfiguration (1) NativeMemoryUsageTotal
CompilerInlining NativeMethodSample (21741)
CompilerPhase NetworkUtilization (86)
CompilerQueueUtilization (43) OSInformation (1)
CompilerStatistics (438) ObjectAllocationInNewTLAB
ConcurrentModeFailure ObjectAllocationOutsideTLAB
ContainerCPUThrottling ObjectAllocationSample (1960)
ContainerCPUUsage ObjectCount
ContainerConfiguration ObjectCountAfterGC
Container
查看网络使用情况
PS \openjdk-25> jcmd 1240 JFR.view NetworkUtilization
1240:
Network Utilization
Time Network Interface Read Rate Write Rate
-------- ------------------------------------------------ ---------- ----------
11:03:10 Intel(R) Dual Band Wireless-AC 3165 1.4 kbps 1.9 kbps
11:03:16 Intel(R) Dual Band Wireless-AC 3165 1.3 kbps 1.6 kbps
11:03:21 Intel(R) Dual Band Wireless-AC 3165 75.8 kbps 76.0 kbps
11:13:03 Intel(R) Dual Band Wireless-AC 3165 0 bps 472 bps
11:13:09 Intel(R) Dual Band Wireless-AC 3165 216 bps 1.2 kbps
...
Timespan: 11:03:10 - 11:13:10
指定事件具体名称
指定以jdk.开头的事件,例:jdk.ThreadSleep。
各类事件名称可以查看jdk/lib/jfr下的default.jfc或profile.jfc,若启动JFR时未指定settings,则默认使用的default.jfc。
PS \openjdk-25> jcmd 1240 JFR.view jdk.ThreadSleep
1240:
Java Thread Sleep
Start Time Duration Event Thread Stack Trace Sleep Time
---------- -------- ------------ ----------------------------------------------- ----------
11:14:46 10.4 s container-0 org.apache.catalina.core.StandardServer.await() 10.0 s
11:14:56 10.4 s container-0 org.apache.catalina.core.StandardServer.await() 10.0 s
11:15:07 10.4 s container-0 org.apache.catalina.core.StandardServer.await() 10.0 s
...
Timespan: 11:05:27 - 11:15:27
jfr
jdk中自带的jfr view和jcmd命令的JFR.view使用基本相同,jfr命令主要查看dump出来的.jfr离线文件。
参考链接
Views: 18 · Posted: 2026-01-11
———         Thanks for Reading         ———
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...