当前位置:网站首页>JVM command - jmap: export memory image file & memory usage
JVM command - jmap: export memory image file & memory usage
2022-07-07 06:08:00 【Zhang Junjie 1994】
Study Silicon Valley Song Hongkang JVM From entry to mastery Learning notes of
summary
jmap Full name JVM Memory Map. One of its functions is to obtain dump file ( Heap dump snapshot file , Binary ), You can also get the target Java Process memory related information , Include Java The usage of each area of the reactor 、 Statistics of objects in the heap , Class loading information and so on .
dump file ( Heap dump snapshot file , Binary ) It is a record of the size of memory occupied by some objects and data in memory at the current time , Is a binary file , Special tools are needed to open .
Basic grammar

1. Using grammar can be done in DOS Use... In the window jmap/jmap -h/jmap -help see
2.<executable Represents executable code , For example, use > File name to specify the generated dump Where the file was generated
3.[[email protected]]<……> It is prepared for remote connection
Basic grammar
-dump
Generate Java Heap dump snapshot :dump file
Special :-dump:live Save only live objects in the heap
-heap
Output details of the entire heap space , Include GC Use 、 Heap configuration information , And memory usage information, etc
-histo
Output peer information of objects in the heap , Including class 、 Number of instances and total capacity
Special :-histo:live Count only the live objects in the heap
-permstat
With ClassLoader Output permanent memory state information for statistical aperture
only linux/solaris The platform works
-finalizerinfo
Displayed in the F-Queue Waiting in the Finalizer Threads execute finalize Object of method
only linux/solaris The platform works
-F
When a virtual machine process pair -dump When the option has no response , You can use this option to force a build dump file
-h | -help
jamp Help commands used by tools
-J
Pass parameters to jmap Starting up jvm
demonstration
Use 1: Export memory image file (dump file )


Be careful :
- For section 1 This is only done in automatic mode , Manual operation will not be in Full GC Then generate Dump
- Manually generate dump file , Generally, after the instruction is executed, it will generate , Don't wait for it to appear OOM When
- Use automatic method to generate dump file , When there is a OOM Before, Mr. Cheng dump file
- If manual mode is used , Generally, the second 2 Kind of , After all, the living objects in the pile dump The file is relatively small , Convenient for transmission and analysis
Manual way
jmap -dump:format=b,file=<filename.hprof> <pid>
jmap -dump:live,format=b,file=<filename.hprof> <pid>



production dump file 

You will find the exported hprof The file will get bigger and bigger , Because with the implementation of the application , There will also be more and more relevant data , Of course, if your parameter configuration has -dump:live Parameter words , representative hprof Save only objects in the heap . , So you generated hprof The file may also become smaller .
In the actual production environment , You made hprof There may be hundreds of files mb size , So the file is a little big ,dump If the instruction has live after , such hprof The file may not be that big , On the ground oom Most of the reasons for the situation are gc It is caused by the survival of objects that cannot be recycled , So the actual production environment , Most of them use -dump:live Instructions
Automatic way
When the program happens oom When you quit the app , Some homeopathic information will disappear with the termination of the program , So reproduce oom The problem is more difficult , If it can happen oom When , Auto export dump Documents are better .
-XX:+HeapDumpOnOutOfMemoryError: When the program happens oom When , Export the current... Of the application dump file .
-XX:HeapDumpPath=<filename.hprof> Specify where to save the heap snapshot ..
such as :
-Xmx100m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\m.hprof
The specific use is as follows :


Wait after starting the program

Happen when oom For a moment , Immediately, a hprof File out
Use 2: Display heap memory information
jmap -heap process id
jmap -heap process id It's just a heap of information at a point in time , and jstat You can add parameters later , You can specify time to dynamically observe data changes , And graphical interface tools , for example jvisualvm etc. , They can dynamically display relevant information in the form of charts , More intuitive
Examples are as follows :

The contents of the document :
The file contains configuration information of heap space , Occupation of new and old generations ,
jmap -histo process id
Output peer information of objects in the heap , Including class 、 Number of instances and total capacity , It is also the object information in memory at this moment
Examples are as follows :
边栏推荐
- DC-7靶机
- 谈fpga和asic的区别
- [InstallShield] Introduction
- Red Hat安装内核头文件
- Mysql-centos7 install MySQL through yum
- Introduction to the extension implementation of SAP Spartacus checkout process
- 从“跑分神器”到数据平台,鲁大师开启演进之路
- Ctfshow-- common posture
- Flask1.1.4 werkzeug1.0.1 source code analysis: start the process
- Add salt and pepper noise or Gaussian noise to the picture
猜你喜欢

C note 13

ML之shap:基于adult人口普查收入二分类预测数据集(预测年收入是否超过50k)利用shap决策图结合LightGBM模型实现异常值检测案例之详细攻略
![R language [logic control] [mathematical operation]](/img/93/06a306561e3e7cb150d243541cc839.png)
R language [logic control] [mathematical operation]

数字IC面试总结(大厂面试经验分享)

From "running distractor" to data platform, Master Lu started the road of evolution
![C. colonne Swapping [tri + Simulation]](/img/0e/64d17980d3ec0051cdfb5fdb34e119.png)
C. colonne Swapping [tri + Simulation]

老板总问我进展,是不信任我吗?(你觉得呢)

SAP Spartacus checkout 流程的扩展(extend)实现介绍

SAP ABAP BDC (batch data communication) -018

Nvisual network visualization
随机推荐
Randomly generate session_ id
nVisual网络可视化
一个简单的代数问题的求解
PowerPivot——DAX(函数)
Three level menu data implementation, nested three-level menu data
【日常训练--腾讯精选50】292. Nim 游戏
Dc-7 target
STM32按键状态机2——状态简化与增加长按功能
cf:C. Column Swapping【排序 + 模拟】
SubGHz, LoRaWAN, NB-IoT, 物联网
目标检测中的损失函数与正负样本分配:RetinaNet与Focal loss
每秒10W次分词搜索,产品经理又提了一个需求!!!(收藏)
Industrial Finance 3.0: financial technology of "dredging blood vessels"
STM32 key state machine 2 - state simplification and long press function addition
Digital IC interview summary (interview experience sharing of large manufacturers)
Harmonyos practice - Introduction to development, analysis of atomized services
Solve pod install error: FFI is an incompatible architecture
苹果cms V10模板/MXone Pro自适应影视电影网站模板
If you don't know these four caching modes, dare you say you understand caching?
Go language context explanation