[转帖]Analyzing Threads

analyzing,threads · 浏览次数 : 0

小编点评

**Memory Analyzer Queries for Thread Overview:** * **Thread Overview:** Provides a visual overview of all threads in the heap dump, including thread name, object, context classloader, and more. * **Max. Locals' Retained Heap:** Shows the maximum retained heap of each stack frame's locals, helping to identify memory-intensive objects. * **Stack Details:** Allows analysis of a single thread by providing thread state, priority, and stack trace. * **Threads Stacks in Dumps:** Provides more information about thread stacks in DTFJ-based dumps, including thread state, priority, and method calls. * **Stack frames as pseudo-objects:** Shows all stack frames as pseudo-objects, with information about the method running in the frame. * **Stack frames as pseudo-classes:** Shows all methods as pseudo-classes, with information about the method type and size. * **Outbound References Tree:** Provides a visual representation of the outbound references between threads and objects. * **Class histogram:** Provides a breakdown of the methods and objects in the heap dump, including size and type information.

正文

https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Ftasks%2Fcomparingdata.html&cp%3D54_3_11

 

Memory Analyzer provides several queries to inspect the threads at the moment the snapshot was taken.

Threads Overview

To get an overview of all the threads in the heap dump, use the "Thread Overview" button in the toolbar, as shown on the image below. Alternatively one could use the Query Browser > Thread Overview and Stacks query:

screen shot of thread overview

The query provide some properties like thread name, thread object, Context Classloader, and more for each of the threads.

Some heap dump formats (e.g. HPROF dumps from recent Java 6 VMs and IBM system dumps) contain information about the call stacks of threads, and the Java local objects per stack frame. The Max. Locals' Retained Heap column shows the maximum retained heap of each stack frame's locals which helps quickly explore why a thread is retaining a lot of heap. When a stack frame is the first selected item the Inspector view shows the class of the method of the frame. The context menu for a stack frame operates on the locals in that frame, and so calculating the precise or approximate retained size when stack frames are selected shows how much memory each stack frame is retaining, or equivalently how much memory would be freed if all the locals of that frame were cleared.
  1. Select all threads using ctrl+A or command+A
  2. Expand one level with shift+numpad-plus
  3. Select all threads and stack frames using ctrl+A or command+A
  4. Calculate retained size using one of the toolbar items Calculate Minimum Retained Size (quick approx.) or Calculate Precise Retained Size
  5. Find the far right hand column Retained Size
  6. Move it to somewhere more convenient by dragging the column header or by clicking on the filter cell, then using shift+up-arrow
  7. Sort on the column
  8. Examine the stack frames retaining the most memory

Exploring the call-stacks and the local Java objects is a powerful feature, giving a debugger like capabilities over a snapshot. It allows analyzing in detail the reasons for memory intensive operations. It also allow using Memory Analyzer not only for memory-related problems, but also for a wide range of other problems such as unresponsive applications.

Threads Details

You can proceed with the analysis of a single thread by using the Java Basics > Thread Details context menu. Memory Analyzer provides an extension point such that extensions can provide semantic information about the thread's activity. The result of the Thread Details query will contain such information (if available), some overview information, and possibly the stacktrace of the thread.

For DTFJ based dumps (IBM system dumps and IBM PHD files with associated java dump) the thread details view gives more information, including the thread state, priority and native stack trace.

Thread details from a DTFJ dump showing DTFJ Name, JNIEnv, Priority, State and Native id.

Threads Stacks in Dumps from IBM VMs

The DTFJ parser provides more control over viewing thread stacks. This is configured using the DTFJ Parser preferences page. The options are as follows:
Normal
Stack frames are only shown in the thread stacks view.
Only stack frames as pseudo-objects
Stack frames are shown in all views such as paths to GC roots, outbound references from threads, as pseudo-objects. Local variables references in the stack frames are shown as outbound references from the frame. This makes it easy to find which stack frames keep objects alive. The size of the stack frame is the size on the Java stack, not the heap.
Stack frames as pseudo-objects and running methods as pseudo-classes
Stack frames are shown in all views such as paths to GC roots, outbound references from threads, as pseudo-objects. Local variables references in the stack frames are shown as outbound references from the frame. This makes it easy to find which stack frames keep objects alive. The stack frames are given a pseudo-type depending based on the method which is running in the frame. By viewing the number of instances of that pseudo-type it is easy to see which methods are running across all the threads and which methods use a lot of stack. This can help solve StackOverflowErrors.
Stack frames as pseudo-objects and all methods as pseudo-classes
Stack frames are shown in all views such as paths to GC roots, outbound references from threads, as pseudo-objects. Local variables references in the stack frames are shown as outbound references from the frame. This makes it easy to find which stack frames keep objects alive. The stack frames are given a pseudo-type depending based on the method which is running in the frame. By viewing the number of instances of that pseudo-type it is easy to see which methods are running across all the threads and which methods use a lot of stack. This can help solve StackOverflowErrors. All other methods are also created as pseudo-class objects. The size of the method pseudo-class object is the size of the byte code and JITted code, which in other modes is accumulated into the size of the defining class. This makes it easy to find method which consume a lot of non-heap memory for byte code and JITted code.

Normal operation with stack frames not considered as objects.

outbound references from thread without stack frames as objects

Stack frames as pseudo-objects.

Note that the type of the stack frame is <stack frame>.

outbound references from thread with stack frames as objects

Stack frames as pseudo-objects and running methods as pseudo-classes.

Note the different types for the stack frame such as java.io.FileStream.getBytes([BIII)I;.

outbound references from thread with stack frames as objects and methods as classes

The class histogram shows that only running methods are pseudo-classes, and the size of the class object is 0.

class histogram showing running methods as pseudo-classes

Stack frames as pseudo-objects and all methods as pseudo-classes.

The outbound references tree looks the same, but the class histogram has a lot more pseudo-classes with 0 instances (i.e. with no running methods), and the pseudo-class objects have a non-zero size. class histogram showing all methods as pseudo-classes

与[转帖]Analyzing Threads相似的内容:

[转帖]Analyzing Threads

https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Ftasks%2Fcomparingdata.html&cp%3D54_3_11 Memory Analyzer provides several

[转帖]The USE Method

Boeing 707 Emergency Checklist(1969) The Utilization Saturation and Errors (USE) Method is a methodology for analyzing the performance of any system.

[转帖]

Linux ubuntu20.04 网络配置(图文教程) 因为我是刚装好的最小系统,所以很多东西都没有,在开始配置之前需要做下准备 环境准备 系统:ubuntu20.04网卡:双网卡 网卡一:供连接互联网使用网卡二:供连接内网使用(看情况,如果一张网卡足够,没必要做第二张网卡) 工具: net-to

[转帖]

https://cloud.tencent.com/developer/article/2168105?areaSource=104001.13&traceId=zcVNsKTUApF9rNJSkcCbB 前言 Redis作为高性能的内存数据库,在大数据量的情况下也会遇到性能瓶颈,日常开发中只有时刻

[转帖]ISV 、OSV、 SIG 概念

ISV 、OSV、 SIG 概念 2022-10-14 12:29530原创大杂烩 本文链接:https://www.cndba.cn/dave/article/108699 1. ISV: Independent Software Vendors “独立软件开发商”,特指专门从事软件的开发、生产、

[转帖]Redis 7 参数 修改 说明

2022-06-16 14:491800原创Redis 本文链接:https://www.cndba.cn/dave/article/108066 在之前的博客我们介绍了Redis 7 的安装和配置,如下: Linux 7.8 平台 Redis 7 安装并配置开机自启动 操作手册https://ww

[转帖]HTTPS中间人攻击原理

https://www.zhihu.com/people/bei-ji-85/posts 背景 前一段时间,公司北京地区上线了一个HTTPS防火墙,用来监听HTTPS流量。防火墙上线之前,邮件通知给管理层,我从我老大那里听说这个事情的时候,说这个有风险,然后意外地发现,很多人原来都不知道HTTPS防

[转帖]关于字节序(大小端)的一点想法

https://www.zhihu.com/people/bei-ji-85/posts 今天在一个技术群里有人问起来了,当时有一些讨论(不完全都是我个人的观点),整理一下: 为什么网络字节序(多数情况下)是大端? 早年设备的缓存很小,先接收高字节能快速的判断报文信息:包长度(需要准备多大缓存)、地

[转帖]awk提取某一行某一列的数据

https://www.jianshu.com/p/dbcb7fe2da56 1、提取文件中第1列数据 awk '{print $1}' filename > out.txt 2、提取前2列的文件 awk `{print $1,$2}' filename > out.txt 3、打印完第一列,然后打

[转帖]awk 中 FS的用法

https://www.cnblogs.com/rohens-hbg/p/5510890.html 在openwrt文件 ar71xx.sh中 查询设备类型时,有这么一句, machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /