网站首页 > 技术文章 正文
查看java进程
jcmd -l #限当前用户
jps -l #限当前用户
ps -ef | grep java
线程栈Thread Dump
jstack ${pid} | more
jcmd ${pid} Thread.print | more
堆直方图
jmap -histo ${pid} | more #输出包括死对象
jmap -histo:live ${pid} | more #输出前会先执行full GC
jcmd ${pid} GC.class_histogram | more #输出前会先执行full GC
堆转储
jcmd ${pid} GC.heap_dump > ${file}.hprof
jmap -dump:live,file=${file}.hprof ${pid}
查看GC情况
jstat -gcutil ${pid} [interval [count]]
$ jstat -gcutil 13034
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
50.05 50.05 0.00 0.80 54.78 56.93 39 0.038 0 0.000 0.038
字段说明:
- S0: Survivor space 0 utilization as a percentage of the space’s current capacity.
- S1: Survivor space 1 utilization as a percentage of the space’s current capacity.
- E: Eden space utilization as a percentage of the space’s current capacity.
- O: Old space utilization as a percentage of the space’s current capacity.
- M: Metaspace utilization as a percentage of the space’s current capacity.
- CCS: Compressed class space utilization as a percentage.
- YGC: Number of young generation GC events.
- YGCT: Young generation garbage collection time.
- FGC: Number of full GC events.
- FGCT: Full garbage collection time.
- GCT: Total garbage collection time.
-gccause选项与-gcutil一样,但是会多显示两个字段。
$ jstat -gccause 13034 1s 100
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT LGCC GCC
50.05 0.00 39.49 0.86 54.79 56.93 2926 2.209 0 0.000 2.209 Allocation Failure No GC
0.00 50.05 12.51 0.86 54.79 56.93 2929 2.211 0 0.000 2.211 Allocation Failure No GC
字段说明:
- LGCC: Cause of last garbage collection
- GCC: Cause of current garbage collection
查到堆空间统计信息
jstat -gc ${pid} [interval [count]]
$ jstat -gc 13034
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
2048.0 2048.0 1025.0 0.0 8192.0 0.0 38912.0 336.1 4864.0 2664.8 512.0 291.5 1054 0.814 0 0.000 0.814
字段说明:
- S0C: Current survivor space 0 capacity (kB).
- S1C: Current survivor space 1 capacity (kB).
- S0U: Survivor space 0 utilization (kB).
- S1U: Survivor space 1 utilization (kB).
- EC: Current eden space capacity (kB).
- EU: Eden space utilization (kB).
- OC: Current old space capacity (kB).
- OU: Old space utilization (kB).
- MC: Metaspace capacity (kB).
- MU: Metacspace utilization (kB).
- CCSC: Compressed class space capacity (kB).
- CCSU: Compressed class space used (kB).
- YGC: Number of young generation garbage collection events.
- YGCT: Young generation garbage collection time.
- FGC: Number of full GC events.
- FGCT: Full garbage collection time.
- GCT: Total garbage collection time.
JVM参数
jcmd ${pid} VM.flags
jinfo -flags ${pid} # 输出信息与jcmd ${pid} VM.flags一样,还包括jcmd ${pid} VM.command_line的信息
jinfo -flag ${参数名} ${pid} # 指定VM参数值
jinfo -flag [+|-]${参数名} ${pid} # 设置或取消指定M参数的布尔值
jinfo -flag ${参数名}=${参数值} ${pid} # 设置指定java虚拟机的参数的值。
### 示例 ###
$ jinfo -flag HeapDumpAfterFullGC 392 # 查询392进程的HeapDumpAfterFullGC值,可以看到是关闭状态
-XX:-HeapDumpAfterFullGC
$ jinfo -flag +HeapDumpAfterFullGC 392 #设置HeapDumpAfterFullGC状态为开启
$ jinfo -flag HeapDumpAfterFullGC 392 # 再次查看
-XX:+HeapDumpAfterFullGC
$ jinfo -flag -HeapDumpAfterFullGC 392 # 设置HeapDumpAfterFullGC状态为关闭
$ jinfo -flag HeapDumpAfterFullGC 392 # 再次查看
-XX:-HeapDumpAfterFullGC
### java -XX:+PrintFlagsFinal -version | grep manageable
### 查看哪些VM参数支持动态配置
$ java -XX:+PrintFlagsFinal -version | grep manageable
intx CMSAbortablePrecleanWaitMillis = 100 {manageable}
intx CMSTriggerInterval = -1 {manageable}
intx CMSWaitDuration = 2000 {manageable}
bool HeapDumpAfterFullGC = false {manageable}
bool HeapDumpBeforeFullGC = false {manageable}
bool HeapDumpOnOutOfMemoryError = false {manageable}
ccstr HeapDumpPath = {manageable}
uintx MaxHeapFreeRatio = 100 {manageable}
uintx MinHeapFreeRatio = 0 {manageable}
bool PrintClassHistogram = false {manageable}
bool PrintClassHistogramAfterFullGC = false {manageable}
bool PrintClassHistogramBeforeFullGC = false {manageable}
bool PrintConcurrentLocks = false {manageable}
bool PrintGC = false {manageable}
bool PrintGCDateStamps = false {manageable}
bool PrintGCDetails = false {manageable}
bool PrintGCID = false {manageable}
bool PrintGCTimeStamps = false {manageable}
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
其它
jcmd ${pid} VM.version # 查看JVM版本
jcmd ${pid} VM.uptime # 查看JVM启动时间
jcmd ${pid} VM.system_properties # 查看JVM环境系统属性
jcmd ${pid} help # 该JVM支持的命令
猜你喜欢
- 2024-10-19 Java高频面试题之Linux(java面试 linux)
- 2024-10-19 性能测试能力提升-JVM GC监控和优化
- 2024-10-19 排查GC问题常用的工具(排查问题的方式有哪些)
- 2024-10-19 开发好物推荐8之自动化部署插件,再也不用登录SSH
- 2024-10-19 20道阿里巴巴中高级java面试题详解,把这些弄懂offer拿到你手软
- 2024-10-19 Java Web实战篇:发布和运维必备的12条Linux命令
- 2024-10-19 Java工程师常用Linux命令大全(linux javac)
- 2024-10-19 玩转linux下启动jar和关闭jar方式(java程序员必看)
- 2024-10-19 超详细的EFK安装部署教程--环境准备篇
- 2024-10-19 为什么阿里架构师是这样定位Java性能问题的?这几点总结的很详细
- 最近发表
- 标签列表
-
- cmd/c (64)
- c++中::是什么意思 (83)
- 标签用于 (65)
- 主键只能有一个吗 (66)
- c#console.writeline不显示 (75)
- pythoncase语句 (81)
- es6includes (73)
- sqlset (64)
- windowsscripthost (67)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- chromepost (65)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- & (66)
- java (73)
- js数组插入 (83)
- linux删除一个文件夹 (65)
- mac安装java (72)
- eacces (67)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)