JVM调优命令-jmap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
[root@localhost jdk1.7.0_79] # jmap --help Usage: jmap [option] <pid> (to connect to running process) jmap [option] <executable <core> (to connect to a core file ) jmap [option] [server_id@]<remote server IP or hostname > (to connect to remote debug server) where <option> is one of: <none> to print same info as Solaris pmap -heap to print java heap summary -histo[:live] to print histogram of java object heap; if the "live" suboption is specified, only count live objects -permstat to print permanent generation statistics -finalizerinfo to print information on objects awaiting finalization -dump:<dump-options> to dump java heap in hprof binary format dump-options: live dump only live objects; if not specified, all objects in the heap are dumped. format =b binary format file =< file > dump heap to < file > Example: jmap -dump:live, format =b, file =heap.bin <pid> -F force. Use with -dump:<dump-options> <pid> or -histo to force a heap dump or histogram when <pid> does not respond. The "live" suboption is not supported in this mode. -h | -help to print this help message -J<flag> to pass <flag> directly to the runtime system |
命令格式
1
2
3
|
jmap [ option ] pid jmap [ option ] executable core jmap [ option ] [server- id @]remote- hostname -or-IP |
参数
option:选项参数,不可同时使用多个选项参数
pid:java进程id,命令ps -ef | grep java获取
executable:产生核心dump的java可执行文件
core:需要打印配置信息的核心文件
remote-hostname-or-ip:远程调试的主机名或ip
server-id:可选的唯一id,如果相同的远程主机上运行了多台调试服务器,用此选项参数标识服务器
options参数
dump : 生成堆转储快照
F : 当-dump没有响应时,强制生成dump快照
示例
-dump
dump堆到文件,format指定输出格式,live指明是活着的对象,file指定文件名
1
2
3
|
[root@localhost jdk1.7.0_79] # jmap -dump:live,format=b,file=dump.hprof 24971 Dumping heap to /usr/local/java/jdk1 .7.0_79 /dump .hprof ... Heap dump file created |
-heap
打印heap的概要信息,GC使用的算法,heap的配置及使用情况,可以用此来判断内存目前的使用情况以及垃圾回收情况
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
[root@localhost jdk1.7.0_79] # jmap -heap 24971 Attaching to process ID 24971, please wait... Debugger attached successfully. Server compiler detected. JVM version is 24.79-b02 using thread- local object allocation. Parallel GC with 4 thread(s) Heap Configuration: MinHeapFreeRatio = 0 MaxHeapFreeRatio = 100 MaxHeapSize = 4146069504 (3954.0MB) NewSize = 1310720 (1.25MB) MaxNewSize = 17592186044415 MB OldSize = 5439488 (5.1875MB) NewRatio = 2 SurvivorRatio = 8 PermSize = 21757952 (20.75MB) MaxPermSize = 85983232 (82.0MB) G1HeapRegionSize = 0 (0.0MB) Heap Usage: PS Young Generation Eden Space: capacity = 517996544 (494.0MB) used = 151567520 (144.54605102539062MB) free = 366429024 (349.4539489746094MB) 29.26033421566612% used From Space: capacity = 41943040 (40.0MB) used = 0 (0.0MB) free = 41943040 (40.0MB) 0.0% used To Space: capacity = 40370176 (38.5MB) used = 0 (0.0MB) free = 40370176 (38.5MB) 0.0% used PS Old Generation capacity = 115343360 (110.0MB) used = 32927184 (31.401809692382812MB) free = 82416176 (78.59819030761719MB) 28.54709972034801% used PS Perm Generation capacity = 85983232 (82.0MB) used = 54701200 (52.16712951660156MB) free = 31282032 (29.832870483398438MB) 63.6184506300019% used 20822 interned Strings occupying 2441752 bytes. |
-finalizerinfo
打印等待回收的对象信息,
1
2
3
4
5
6
|
[root@localhost jdk1.7.0_79] # jmap -finalizerinfo 24971 Attaching to process ID 24971, please wait... Debugger attached successfully. Server compiler detected. JVM version is 24.79-b02 Number of objects pending for finalization: 0 |
Number of objects pending
for
finalization: 0
说明当前F-QUEUE队列中并没有等待Fializer线程执行final
izer方法的对象。
-histo
打印堆的对象统计,包括对象数、内存大小等等。jmap -histo:live 这个命令执行,JVM会先触发gc,然后再统计信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
[root@localhost jdk1.7.0_79] # jmap -histo:live 24971 | more num #instances #bytes class name ---------------------------------------------- 1: 100134 14622728 <constMethodKlass> 2: 100134 12830128 <methodKlass> 3: 88438 12708392 [C 4: 8271 10163584 <constantPoolKlass> 5: 27806 9115784 [B 6: 8271 6225312 <instanceKlassKlass> 7: 6830 5632192 <constantPoolCacheKlass> 8: 86717 2081208 java.lang.String 9: 2264 1311720 <methodDataKlass> 10: 10880 870400 java.lang.reflect.Method 11: 8987 869888 java.lang.Class 12: 13330 747264 [[I 13: 11808 733872 [S 14: 20110 643520 java.util.concurrent.ConcurrentHashMap$HashEntry 15: 18574 594368 java.util.HashMap$Entry 16: 3668 504592 [Ljava.util.HashMap$Entry; 17: 30698 491168 java.lang.Integer 18: 2247 486864 [I 19: 7486 479104 java.net.URL 20: 8032 453616 [Ljava.lang.Object; 21: 10259 410360 java.util.LinkedHashMap$Entry 22: 699 380256 <objArrayKlassKlass> 23: 5782 277536 org.apache.catalina.loader.ResourceEntry 24: 8327 266464 java.lang.ref.WeakReference 25: 2374 207928 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry; 26: 3440 192640 java.util.LinkedHashMap 27: 4779 191160 java.lang.ref.SoftReference 28: 3576 171648 java.util.HashMap 29: 10080 161280 java.lang.Object |
jmap -histo:live 24971 | grep com.yuhuo 查询类名包含com.yuhuo的信息
jmap -histo:live 24971 | grep com.yuhuo > histo.txt 保存信息到histo.txt文件
附 - jmap输出中class name非自定义类的说明:
BaseType Character | Type | Interpretation |
---|---|---|
B | byte | signed byte |
C | char | Unicode character |
D | double | double-precision floating-point value |
F | float | single-precision floating-point value |
I | int | integer |
J | long | long integer |
L; | reference | an instance of class |
S | short | signed short |
Z | boolean | true or false |
[ | reference | one array dimension,[I表示int[] |
-permstat
打印Java堆内存的永久区的类加载器的智能统计信息。对于每个类加载器而言,它的名称、活跃度、地址、父类加载器、它所加载的类的数量和大小都会被打印。此外,包含的字符串数量和大小也会被打印。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@localhost jdk1.7.0_79] # jmap -permstat 24971 Attaching to process ID 24971, please wait... Debugger attached successfully. Server compiler detected. JVM version is 24.79-b02 finding class loader instances .. done . computing per loader stat .. done . please wait.. computing liveness....................................................liveness analysis may be inaccurate ... class_loader classes bytes parent_loader alive? type <bootstrap> 3034 18149440 null live <internal> 0x000000070a88fbb8 1 3048 null dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x000000070a914860 1 3064 0x0000000709035198 dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x000000070a9fc320 1 3056 0x0000000709035198 dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x000000070adcb4c8 1 3064 0x0000000709035198 dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x000000070a913760 1 1888 0x0000000709035198 dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x0000000709f3fd40 1 3032 null dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x000000070923ba78 1 3088 0x0000000709035260 dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x000000070a88fff8 1 3048 null dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 0x000000070adcbc58 1 1888 0x0000000709035198 dead sun /reflect/DelegatingClassLoader @0x0000000703c50b58 |
-F
强制模式。如果指定的pid没有响应,请使用jmap -dump或jmap -histo选项。此模式下,不支持live子选项。
JVM调优命令-jmap的更多相关文章
- jvm系列(四):jvm调优-命令大全(jps jstat jmap jhat jstack jinfo)
文章同步发布于github博客地址,阅读效果更佳,欢迎品尝 运用jvm自带的命令可以方便的在生产监控和打印堆栈的日志信息帮忙我们来定位问题!虽然jvm调优成熟的工具已经有很多:jconsole.大名鼎 ...
- [转]jvm调优-命令大全(jps jstat jmap jhat jstack jinfo)
运用jvm自带的命令可以方便的在生产监控和打印堆栈的日志信息帮忙我们来定位问题!虽然jvm调优成熟的工具已经有很多:jconsole.大名鼎鼎的VisualVM,IBM的Memory Analyzer ...
- JVM调优 — 命令大全(jps jstat jmap jhat jstack jinfo)(转)
运用jvm自带的命令可以方便的在生产监控和打印堆栈的日志信息帮忙我们来定位问题!虽然jvm调优成熟的工具已经有很多:jconsole.大名鼎鼎的VisualVM,IBM的Memory Analyzer ...
- jvm调优-命令大全(jps jstat jmap jhat jstack jinfo)
现实企业级Java开发中,有时候我们会碰到下面这些问题: OutOfMemoryError,内存不足 内存泄露 线程死锁 锁争用(Lock Contention) Java进程消耗CPU过高 运用jv ...
- Java虚拟机(五):JVM调优命令
运用jvm自带的命令可以方便的在生产监控和打印堆栈的日志信息帮忙我们来定位问题!虽然jvm调优成熟的工具已经有很多:jconsole.大名鼎鼎的VisualVM,IBM的Memory Analyzer ...
- jvm系列(四):jvm调优-命令篇
运用jvm自带的命令可以方便的在生产监控和打印堆栈的日志信息帮忙我们来定位问题!虽然jvm调优成熟的工具已经有很多:jconsole.大名鼎鼎的VisualVM,IBM的Memory Analyzer ...
- 类加载机制与JVM调优命令
一.类加载过程 类加载:类加载器将.class字节码文件加载进Java虚拟机的内存中. 加载:在硬盘上查找并通过IO读入字节码文件 连接:执行校验.准备.解析(可选)步骤 校验:校验字节码文件的正确性 ...
- jvm调优命令
JDK监控和故障jps,jstat,jmap,jhat,jstack.jinfo jps ,JVM Process Status Tool,显示指定系统内所有的HotSpot虚拟机进程. jstat ...
- JVM调优命令-jhat
jhat JVM Heap Analysis Tool命令是与jmap搭配使用,用来分析jmap生成的dump,jhat内置了一个微型的HTTP/HTML服务器,生成dump的分析结果后,可以在浏览器 ...
随机推荐
- 背水一战 Windows 10 (55) - 控件(集合类): SemanticZoom, ISemanticZoomInformation
[源码下载] 背水一战 Windows 10 (55) - 控件(集合类): SemanticZoom, ISemanticZoomInformation 作者:webabcd 介绍背水一战 Wind ...
- TwoSum / Three Sum
Let's begin with a naive method. We first need to sort the array A[n]. And we want to solve the prob ...
- 201621123018《java程序设计》第12周作业总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多流与文件相关内容. 2. 面向系统综合设计-图书馆管理系统或购物车 使用流与文件改造你的图书馆管理系统或购物车. 2.1 简述如何 ...
- CF1146H Satanic Panic
题目传送门 Description 给定二维平面内\(n\)个点\((n\leq 300)\),求能组成五角星(不要求正五角星)的五元组个数. Solution 一道小清新的寄蒜几盒计算几何题,代码不 ...
- 异常处理,约束,MD5加密日志处理
程序运行过程中产生的错误, 不正常 def chufa(a, b): try: # 尝试执行xxx代码 ret = a/b # 如果这里出现了错误. 异常. 系统内部会产生一个异常对象. 系统会把这个 ...
- mysql查询语句分析 explain/desc用法
explain或desc显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. explain 数据表 或 desc 数据表 显示数据表各字段含义 ...
- 全世界最顶级黑客同时沸腾在DEF CON 25,是怎样一种体验?
2017,我在这里!圆你黑客梦!! 被称为黑客“世界杯”与“奥斯卡”的美国黑帽技术大会Black Hat和世界黑客大会DEF CON 是众多黑客心中最神圣的梦! 有位小表弟告诉我说:Black ...
- Linux巩固记录(5) hadoop 2.7.4下自己编译代码并运行MapReduce程序
程序代码为 ~\hadoop-2.7.4\share\hadoop\mapreduce\sources\hadoop-mapreduce-examples-2.7.4-sources\org\apac ...
- mysql创建账号及管理权限
mysql创建账号及管理权限 0.mysql版本8.0.15,服务器版本:RHEL 6.5 1.创建用户名密码 mysql> use mysql; mysql> create user ' ...
- Python(28)---模块和包的基本概念
一.模块 定义:在python中,一个 .py 文件就称为一个模块 使用模块的好处:最大的好处就是提高了代码的可维护性 分类(三种): python标准库 第三方模块 应用程序自定义模块 模块导入方法 ...