JVM调优之jhat

2024-04-19 09:58
文章标签 java jvm 调优 jhat

本文主要是介绍JVM调优之jhat,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

jhat - Java Heap Analysis Tool

JHAT命令解析Java堆转储文件并启动WebServer。jhat允许您使用您最喜欢的WebBrowser浏览堆转储。JHAT支持预先设计的查询(例如“show all instances of a known class "Foo"”)以及OQL((Object Query Language对象查询语言)——一种查询堆转储的类似SQL的查询语言。可以在http://localhost:7000/oqlhelp/查看有关OQL的使用说明。这个工具是实验性的,在JDK的未来版本中可能不可用。

这里有一些生成java堆转储文件的方法:

  • jmap -dump 在运行时获取堆转储
  • jconsole  在运行时通过hotspotdiagnosticmxbean获取堆转储
  • -XX:+HeapDumpOnOutOfMemoryError  启动java程序时通过使用-XX:+HeapDumpOnOutOfMemoryError命令,使程序在抛出OutOfMemoryError时自动生成堆转储
  • 使用hprof
jhat -h
Usage:  jhat [-stack <bool>] [-refs <bool>] [-port <port>] [-baseline <file>] [-debug <int>] [-version] [-h|-help] <file>-J<flag>          Pass <flag> directly to the runtime system. Forexample, -J-mx512m to use a maximum heap size of 512MB-stack false:     Turn off tracking object allocation call stack.-refs false:      Turn off tracking of references to objects-port <port>:     Set the port for the HTTP server.  Defaults to 7000-exclude <file>:  Specify a file that lists data members that shouldbe excluded from the reachableFrom query.-baseline <file>: Specify a baseline object dump.  Objects inboth heap dumps with the same ID and same class willbe marked as not being "new".-debug <int>:     Set debug level.0:  No debug output1:  Debug hprof file parsing2:  Debug hprof file parsing, no server-version          Report version number-h|-help          Print this help and exit<file>            The file to readFor a dump file that contains multiple heap dumps,
you may specify which dump in the file
by appending "#<number>" to the file name, i.e. "foo.hprof#3".All boolean options default to "true"
  • 使用方式:

jhat [ options ] <heap-dump-file>

options

Options,操作选项,如果要用的话必须紧跟在jhat后面。

heap-dump-file

要查看的java二进制堆转储文件. 如果一个 dump file包含了多个heap dumps,可以在文件后面拼接#<number>来查看某个堆, i.e. "foo.hprof#3"。

  • OPTIONS

-stack false/true

关闭对象在堆栈中的追踪,注意,如果在堆转储中分配站点信息不可用,则必须将此标志设置为false。默认值为true。
Turn off tracking object allocation call stack. Note that if allocation site information is not available in the heap dump, you have to set this flag to false. Default is true.


-refs false/true

关闭对对象引用的跟踪。默认值为true。默认情况下,为堆中的所有对象计算返回指针(指向给定对象a.k.a引用或传入引用的对象)。
Turn off tracking of references to objects. Default is true. By default, back pointers (objects pointing to a given object a.k.a referrers or in-coming references) are calculated for all objects in the heap.


-port port-number
指定server端口,默认是7000。


-exclude exclude-file

指定一个列出应从“reachable objects”查询中排除的数据成员的文件。例如,如果文件列出java.lang.string.value,那么每当计算从特定对象“o”可访问的对象列表时,将不考虑涉及java.lang.string.value字段的引用路径。
Specify a file that lists data members that should be excluded from the "reachable objects" query. For example, if the file lists java.lang.String.value, then, whenever list of objects reachable from a specific object "o" are calculated, reference paths involving java.lang.String.value field will not considered.


-baseline baseline-dump-file

指定基线堆转储(baseline heap dump)。两个堆转储中具有相同object ID的的对象将不会标记为“new”。其他对象将标记为“new”。这在比较两个不同的堆转储时很有用。


-debug int

设置debug级别,0表示没有debug输出,这个值越高,输出的模式更详细。

-version

打印版本号并退出。

eg:

jhat -version
jhat version 2.0 (java version 1.8.0_73)


-J<flag>
指定jhat的jvm命令。eg:jhat -J-Xmx512m.

 

这篇关于JVM调优之jhat的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/917220

相关文章

Spring Cloud LoadBalancer 负载均衡详解

《SpringCloudLoadBalancer负载均衡详解》本文介绍了如何在SpringCloud中使用SpringCloudLoadBalancer实现客户端负载均衡,并详细讲解了轮询策略和... 目录1. 在 idea 上运行多个服务2. 问题引入3. 负载均衡4. Spring Cloud Load

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

在 Spring Boot 中使用 @Autowired和 @Bean注解的示例详解

《在SpringBoot中使用@Autowired和@Bean注解的示例详解》本文通过一个示例演示了如何在SpringBoot中使用@Autowired和@Bean注解进行依赖注入和Bean... 目录在 Spring Boot 中使用 @Autowired 和 @Bean 注解示例背景1. 定义 Stud

如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别详解

《如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别详解》:本文主要介绍如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别的相关资料,描述了如何使用海康威视设备网络SD... 目录前言开发流程问题和解决方案dll库加载不到的问题老旧版本sdk不兼容的问题关键实现流程总结前言作为

SpringBoot中使用 ThreadLocal 进行多线程上下文管理及注意事项小结

《SpringBoot中使用ThreadLocal进行多线程上下文管理及注意事项小结》本文详细介绍了ThreadLocal的原理、使用场景和示例代码,并在SpringBoot中使用ThreadLo... 目录前言技术积累1.什么是 ThreadLocal2. ThreadLocal 的原理2.1 线程隔离2

springboot将lib和jar分离的操作方法

《springboot将lib和jar分离的操作方法》本文介绍了如何通过优化pom.xml配置来减小SpringBoot项目的jar包大小,主要通过使用spring-boot-maven-plugin... 遇到一个问题,就是每次maven package或者maven install后target中的ja

Java中八大包装类举例详解(通俗易懂)

《Java中八大包装类举例详解(通俗易懂)》:本文主要介绍Java中的包装类,包括它们的作用、特点、用途以及如何进行装箱和拆箱,包装类还提供了许多实用方法,如转换、获取基本类型值、比较和类型检测,... 目录一、包装类(Wrapper Class)1、简要介绍2、包装类特点3、包装类用途二、装箱和拆箱1、装

如何利用Java获取当天的开始和结束时间

《如何利用Java获取当天的开始和结束时间》:本文主要介绍如何使用Java8的LocalDate和LocalDateTime类获取指定日期的开始和结束时间,展示了如何通过这些类进行日期和时间的处... 目录前言1. Java日期时间API概述2. 获取当天的开始和结束时间代码解析运行结果3. 总结前言在J

Java深度学习库DJL实现Python的NumPy方式

《Java深度学习库DJL实现Python的NumPy方式》本文介绍了DJL库的背景和基本功能,包括NDArray的创建、数学运算、数据获取和设置等,同时,还展示了如何使用NDArray进行数据预处理... 目录1 NDArray 的背景介绍1.1 架构2 JavaDJL使用2.1 安装DJL2.2 基本操

最长公共子序列问题的深度分析与Java实现方式

《最长公共子序列问题的深度分析与Java实现方式》本文详细介绍了最长公共子序列(LCS)问题,包括其概念、暴力解法、动态规划解法,并提供了Java代码实现,暴力解法虽然简单,但在大数据处理中效率较低,... 目录最长公共子序列问题概述问题理解与示例分析暴力解法思路与示例代码动态规划解法DP 表的构建与意义动