JVM探秘:jmap生成内存堆转储快照
本系列笔记主要基于《深入理解Java虚拟机:JVM高级特性与最佳实践 第2版》,是这本书的读书笔记。
jmap 命令用来生成内存堆转储快照,一般称为heapdump或dump文件。
除了使用 jmap 命令,还以通过一些JVM参数让虚拟机在内存溢出时自动dump出快照文件。
| 参数 | 说明 |
|---|---|
| -XX:+HeapDumpOnOutOfMemoryError | 内存溢出时自动导出内存快照 |
| -XX:HeapDumpPath=E:/dumps/ | 导出内存快照时保存的路径 |
所有的JDK工具都可以在Oracle官网的 Java Tools Reference 文档中找到使用说明,这是主要参考,包括命令格式、参数内容、输出信息等等。
jmap 命令格式:
jmap [ options ] pid
jmap [ options ] executable core
jmap [ options ] [ pid ] server-id@ ] remote-hostname-or-IP
jmap 帮助信息:

jmap -dump
jmap 命令使用-dump参数生成内存快照,-dump参数格式如下:
-dump:[live,] format=b, file=filename
举例如下:
jmap -dump:format=b,file=/dumps/jmap.hprof 21060
输出如下:

可见,在指定目录dumps下面生成了堆快照文件。
jmap -heap
jmap 命令使用-heap参数查看堆内存的配置信息,以及堆中各个区域的使用情况,如新生代的Eden和Survivor区,还有老年代。
-heap参数举例如下:
jmap -heap 21060
输出如下:

其他参数
jmap 命令还有很多其他参数,可以参考 Java Tools Reference 文档,列举如下:
<no option>
When no option is used, the jmap command prints shared object mappings. For each shared object loaded in the target JVM, the start address, size of the mapping, and the full path of the shared object file are printed. This behavior is similar to the Oracle Solaris pmap utility.
-dump:[live,] format=b, file=filename
Dumps the Java heap in hprof binary format to filename. The live suboption is optional, but when specified, only the active objects in the heap are dumped. To browse the heap dump, you can use the jhat(1) command to read the generated file.
-finalizerinfo
Prints information about objects that are awaiting finalization.
-heap
Prints a heap summary of the garbage collection used, the head configuration, and generation-wise heap usage. In addition, the number and size of interned Strings are printed.
-histo[:live]
Prints a histogram of the heap. For each Java class, the number of objects, memory size in bytes, and the fully qualified class names are printed. The JVM internal class names are printed with an asterisk (*) prefix. If the live suboption is specified, then only active objects are counted.
-clstats
Prints class loader wise statistics of Java heap. For each class loader, its name, how active it is, address, parent class loader, and the number and size of classes it has loaded are printed.
-F
Force. Use this option with the jmap -dump or jmap -histo option when the pid does not respond. The live suboption is not supported in this mode.
-h
Prints a help message.
-help
Prints a help message.
-Jflag
Passes flag to the Java Virtual Machine where the jmap command is running.
JVM探秘:jmap生成内存堆转储快照的更多相关文章
- JVM探秘2--详解内存溢出OutOfMemoryError异常
JVM运行时内存被划分成多个区域,而除了程序计数器之外,其他几个区都会出现OutOfMemoryError异常,主要原因就是对应内存区域的内存不足以再分配内存,一般要么是内存泄漏了要么就是内存参数设置 ...
- JVM探秘:Java内存区域
本系列笔记主要基于<深入理解Java虚拟机:JVM高级特性与最佳实践 第2版>,是这本书的读书笔记. 概述 Java 虚拟机为程序员分担了很多内存管理的工作,不再像 C/C++ 那样容易出 ...
- 读书笔记jvm探秘之一:内存概况
jvm内存大致可以分为六大块: 堆,虚拟机主要内存,可以形象的说,堆是对象的存储库,几乎所有的对象实例和数组都在此分配内存,当然也死于此,jvm垃圾回收机制(简称GC)主要处理的就是这个地方.它被所有 ...
- Eclipse Memory Analysis进行堆转储文件分析
生成堆转储文件 新建项目,设置Eclispe Java堆的大小: (1)限制Java堆大小:将最小值 -Xms参数与最大值-Xmx参数设置一样可避免堆的扩展 -Xmx20m -Xms2 ...
- JVM探秘:内存溢出
本系列笔记主要基于<深入理解Java虚拟机:JVM高级特性与最佳实践 第2版>,是这本书的读书笔记. 在 Java 虚拟机内存区域中,除了程序计数器外,其他几个内存区域都可能会发生OutO ...
- 使用 Eclipse Memory Analyzer 进行堆转储文件分析
Eclipse Memory Analyzer(MAT)是著名的跨平台集成开发环境 Eclipse Galileo 版本的 33 个组成项目中之一,它是一个功能丰富的 JAVA 堆转储文件分析工具,可 ...
- JVM探秘5---JVM监控命令大全
jps命令---查看JVM进程状况 格式为:jps [options] [hostid] 功能描述: jps是用于查看有权访问的hotspot虚拟机的进程. 当未指定hostid时,默认查看本机jvm ...
- mat 使用 分析 oom 使用 Eclipse Memory Analyzer 进行堆转储文件分析
概述 对于大型 JAVA 应用程序来说,再精细的测试也难以堵住所有的漏洞,即便我们在测试阶段进行了大量卓有成效的工作,很多问题还是会在生产环境下暴露出来,并且很难在测试环境中进行重现.JVM 能够记录 ...
- Heap堆分析(堆转储、堆分析)
一.堆直方图 减少内存使用时一个重要目标,在堆分析上最简单的方法是利用堆直方图.通过堆直方图我们可以快速看到应用内的对象数目,同时不需要进行完整的堆转储(因为堆转储需要一段时间来分析,而且会消耗大量磁 ...
随机推荐
- Hadoop完全高可用集群安装
架构图(HA模型没有SNN节点) 用vm规划了8台机器,用到了7台,SNN节点没用 NN DN SN ZKFC ZK JNN RM NM node1 * * node2 * ...
- python 第一节 脚本 import from reload exec
环境Ubuntu 14.04, 不写交互式命令行了,直接脚本开始. # first Python script import sys print(sys.platform) print(2**4) x ...
- Django配置日志
在settings里配置 # 日志配置 LOGGING = { # 是python的版本 'version': 1, # 是否禁用 'disable_existing_loggers': False, ...
- K8S Kubernetes 简单介绍 转自 http://time-track.cn/kubernetes-trial.html Kubernetes初体验
这段时间学习了一下 git jenkins docker 最近也在看 Kubernetes 感觉写得很赞 也是对自己对于K8S 有了进一步得理解 感谢 倪 大神得Blog 也希望看到这篇Bl ...
- 每天一点点之laravel框架开发 - Laravel5.6去除URL中的index.php
在项目routes/web.php文件中添加了自定义的路由后,访问localhost/index.php/aaa,可以正常访问,但是去掉index.php后,提示404 Not Found 1. 按照 ...
- tx2--开机启动
TX2上电自动开机 参考:http://121.42.13.250/?p=168 问题描述 Jetson TX2在接通电源后,按下板子上的PWOER BTN开机键(S4)后,便能够正常启动.但这对于一 ...
- SpringAOP切入点的表达式
1. 常用的切入点表达式分为: (1)按类型匹配:within 关键字 (2)按函数匹配:execution (3)按bean的id匹配:bean 2.按类匹配的写法 匹配到具体的类:<aop ...
- 详解contextConfigLocation|Spring启动过程详解(转)
原文链接:https://blog.csdn.net/qw222pzx/article/details/78191670 spring的应用初始化流程一直没有搞明白,刚刚又碰到了相关的问题.决定得好好 ...
- Activity LauchMode设置
lauchMode: standard: 标准模式,每次调用startActivity()方法就会产生一个新的实例. singleTop: 如果已经有一个实例位于Activit ...
- POJ 1844:Sum ”滚动“数组
Sum Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10494 Accepted: 6895 Description ...