当前位置:网站首页>JVM调试工具-jmap
JVM调试工具-jmap
2022-06-24 06:39:00 【Angryshark_128】
jmap
jmap命令是一个可以输出所有内存中对象的工具,甚至可以将VM 中的heap,以二进制输出成文本。
打印出某个java进程(使用pid)内存内的,所有‘对象’的情况(如:产生那些对象,及其数量)。
命令用法:jmap [option]
(to connect to running process) 连接到正在运行的进程
jmap [option] <executable <core>
(to connect to a core file) 连接到核心文件
jmap [option] [[email protected]]<remote server IP or hostname>
(to connect to remote debug server) 连接到远程调试服务
pid: 目标进程的PID,进程编号,可以采用ps -ef | grep java 查看java进程的PID;
executable: 产生core dump的java可执行程序;
core: 将被打印信息的core dump文件;
remote-hostname-or-IP: 远程debug服务的主机名或ip;
server-id: 唯一id,假如一台主机上多个远程debug服务;
常用命令
打印Java堆概要信息,包括使用的GC算法、堆配置参数和各代中堆内存使用情况
> jmap -heap 23766
Attaching to process ID 31846, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.71-b01
using thread-local object allocation.
Parallel GC with 4 thread(s)//GC 方式
Heap Configuration: //堆内存初始化配置
MinHeapFreeRatio = 0 //对应jvm启动参数-XX:MinHeapFreeRatio设置JVM堆最小空闲比率(default 40)
MaxHeapFreeRatio = 100 //对应jvm启动参数 -XX:MaxHeapFreeRatio设置JVM堆最大空闲比率(default 70)
MaxHeapSize = 2082471936 (1986.0MB) //对应jvm启动参数-XX:MaxHeapSize=设置JVM堆的最大大小
NewSize = 1310720 (1.25MB)//对应jvm启动参数-XX:NewSize=设置JVM堆的‘新生代’的默认大小
MaxNewSize = 17592186044415 MB//对应jvm启动参数-XX:MaxNewSize=设置JVM堆的‘新生代’的最大大小
OldSize = 5439488 (5.1875MB)//对应jvm启动参数-XX:OldSize=<value>:设置JVM堆的‘老生代’的大小
NewRatio = 2 //对应jvm启动参数-XX:NewRatio=:‘新生代’和‘老生代’的大小比率
SurvivorRatio = 8 //对应jvm启动参数-XX:SurvivorRatio=设置年轻代中Eden区与Survivor区的大小比值
PermSize = 21757952 (20.75MB) //对应jvm启动参数-XX:PermSize=<value>:设置JVM堆的‘永生代’的初始大小
MaxPermSize = 85983232 (82.0MB)//对应jvm启动参数-XX:MaxPermSize=<value>:设置JVM堆的‘永生代’的最大大小
G1HeapRegionSize = 0 (0.0MB)
Heap Usage://堆内存使用情况
PS Young Generation
Eden Space://Eden区内存分布
capacity = 33030144 (31.5MB)//Eden区总容量
used = 1524040 (1.4534378051757812MB) //Eden区已使用
free = 31506104 (30.04656219482422MB) //Eden区剩余容量
4.614088270399305% used //Eden区使用比率
From Space: //其中一个Survivor区的内存分布
capacity = 5242880 (5.0MB)
used = 0 (0.0MB)
free = 5242880 (5.0MB)
0.0% used
To Space: //另一个Survivor区的内存分布
capacity = 5242880 (5.0MB)
used = 0 (0.0MB)
free = 5242880 (5.0MB)
0.0% used
PS Old Generation //当前的Old区内存分布
capacity = 86507520 (82.5MB)
used = 0 (0.0MB)
free = 86507520 (82.5MB)
0.0% used
PS Perm Generation//当前的 “永生代” 内存分布
capacity = 22020096 (21.0MB)
used = 2496528 (2.3808746337890625MB)
free = 19523568 (18.619125366210938MB)
11.337498256138392% used
670 interned Strings occupying 43720 bytes.
打印Java堆中对象直方图,通过该图可以获取每个class的对象数目,占用内存大小和类全名信息,带上:live,则只统计活着的对象
> jmap -histo 23766
23766: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
> jmap -F -histo 23766
Attaching to process ID 23766, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.191-b12
Iterating over heap. This may take a while...
num #instances #bytes class name
----------------------------------------------
1: 245237 26378800 [C
2: 18355 19262448 [B
3: 45062 14682856 [I
4: 245389 5889336 java.util.HashMap$Node
5: 274529 4392464 java.lang.String
6: 44989 4087960 [Ljava.util.HashMap$Node;
7: 68684 3150440 [Ljava.lang.Object;
8: 18342 1841288 java.lang.Class
9: 28573 1828672 java.lang.reflect.Field
10: 42818 1712720 java.util.HashMap
11: 30488 1556088 [Ljava.lang.String;
12: 32420 1037440 java.util.LinkedHashMap$Entry

打印等待回收的对象信息
> jmap -finalizerinfo 23766
Attaching to process ID 23766, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.191-b12
Number of objects pending for finalization: 0
# 说明当前F-QUEUE队列中并没有等待Fializer线程执行finalizer方法的对象。
以hprof二进制格式将Java堆信息输出到文件内,该文件可以用MAT、VisualVM或jhat等工具查看
# 输出到文件,注意此时会暂停应用
> jmap -dump:live,format=b,file=heapDump 23766
Dumping heap to /home/oidd/heapDump ...
Heap dump file created
# 通过浏览器访问
> jhat -port 5000 heapDump
Reading from heapDump...
Dump file created Thu Sep 17 08:43:21 CST 2020
Snapshot read, resolving...
Resolving 314429 objects...
Chasing references, expect 62 dots..............................................................
Eliminating duplicate references..............................................................
Snapshot resolved.
Started HTTP server on port 5000
Server is ready.
访问:http://localhost:5000/

边栏推荐
- 如何低成本构建一个APP
- c#:互斥锁的使用
- 35 year old crisis? It has become a synonym for programmers
- 学生管理系统页面跳转及数据库连接
- How to register the cloud service platform and what are the advantages of cloud server
- Multi sensor fusion track fusion
- mysql中的 ON UPDATE CURRENT_TIMESTAMP
- About Stacked Generalization
- 云上本地化运营,东非第一大电商平台Kilimall的出海经
- 记录--关于virtual studio2017添加报表控件的方法--Reportview控件
猜你喜欢

leetcode:剑指 Offer 26:判断t1中是否含有t2的全部拓扑结构

RealNetworks vs. 微软:早期流媒体行业之争

你有一个机会,这里有一个舞台

About Stacked Generalization

Typora charges? Build vs Code markdown writing environment

Computing power and intelligence of robot fog

You have a chance, here is a stage

Arduino融资3200万美元,进军企业市场

数据同步工具 DataX 已经正式支持读写 TDengine

leetcode:1856. 子数组最小乘积的最大值
随机推荐
Oracle SQL comprehensive application exercises
The data synchronization tool dataX has officially supported reading and writing tdengine
RS485 serial port wiring description of smart lamp post smart gateway
Page Jump and database connection of student management system
线程安全与实现方法
Become TD hero, a superhero who changes the world with Technology | invitation from tdengine community
How to operate the little red book account: making good use of the theory of long tail words
C语言学生管理系统——可检查用户输入合法性,双向带头循环链表
原神方石机关解密
Code scanning | a sharp tool for controlling code quality
记录--关于virtual studio2017添加报表控件的方法--Reportview控件
What are the audio formats? Can the audio format be converted
Go breakpoint continuation
Another double win! Tencent's three security achievements were selected into the 2021 wechat independent innovation achievements recommendation manual
Spark累加器和廣播變量
你有一个机会,这里有一个舞台
缓存操作rockscache原理图
Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.
【愚公系列】2022年6月 ASP.NET Core下CellReport报表工具基本介绍和使用
Spark累加器和广播变量