当前位置:网站首页>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/

边栏推荐
- [problem solving] virtual machine configuration static IP
- C language student management system - can check the legitimacy of user input, two-way leading circular linked list
- On BOM and DOM (1): overview of BOM and DOM
- Computing power and intelligence of robot fog
- Laravel文档阅读笔记-Laravel Str slug() Function Example
- 机器人迷雾之算力与智能
- [binary tree] - middle order traversal of binary tree
- JSON formatting method advantages of JSON over XML
- leetcode:84. 柱状图中最大的矩形
- GPU frequency of zhanrui chip
猜你喜欢

云上本地化运营,东非第一大电商平台Kilimall的出海经

C language student management system - can check the legitimacy of user input, two-way leading circular linked list

. Net7 miniapi (special part):preview5 optimizes JWT verification (Part 1)

面渣逆袭:MySQL六十六问,两万字+五十图详解

Arduino raised $32million to enter the enterprise market

机器人迷雾之算力与智能

In the middle of the year, I have prepared a small number of automated interview questions. Welcome to the self-test
![Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.](/img/2c/d04f5dfbacb62de9cf673359791aa9.png)
Command ‘[‘where‘, ‘cl‘]‘ returned non-zero exit status 1.

Computing power and intelligence of robot fog

【JUC系列】Executor框架之CompletionFuture
随机推荐
Nine unique skills of Huawei cloud low latency Technology
Record -- about the method of adding report control to virtual studio2017 -- reportview control
虚拟文件系统
LuChen technology was invited to join NVIDIA startup acceleration program
CloudCompare&PCL 点云裁剪(基于裁剪盒)
What is the OSI seven layer model? What is the role of each layer?
雲監控系統 HertzBeat v1.1.0 發布,一條命令開啟監控之旅!
机器人迷雾之算力与智能
Go breakpoint continuation
Internet cafe management system and database
In the middle of the year, I have prepared a small number of automated interview questions. Welcome to the self-test
项目Demo
How to operate the little red book account: making good use of the theory of long tail words
FreeRTOS MPU makes the system more robust!
Leetcode: Sword finger offer 26: judge whether T1 contains all topologies of T2
go 断点续传
如何低成本构建一个APP
What is domain name resolution? What if the domain name cannot be resolved?
【愚公系列】2022年6月 ASP.NET Core下CellReport报表工具基本介绍和使用
Cloud native high availability and Disaster Recovery Series (I): pod break up scheduling