Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MAT, a sharp tool for memory leak analysis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

MAT:Memory Analyzer Tool

Is a fast and powerful java heap analyzer that can analyze and find memory leaks and other problems

Get the dump file stored in the memory snapshot, and you can use it to analyze

Download address: http://www.eclipse.org/mat/downloads.php

Basic concepts:

Shallow Size: the amount of memory occupied by the object itself

Retained Size: the current object size + the object size to which it refers directly / indirectly, the sum of the two

Analyze memory leaks due to code through MAT:

-take a memory snapshot (.hprof file):

Method 1: set it in tomcat/bin/catalina.sh so that heap information is printed when jvm crashes:

-XX:+HeapDumpOnOutOfMemoryError-XX:HeapDumpPath=path_address

Method 2: use the commands jps and jmap to get a memory snapshot

Jps-m-l lists the process status information running in JVM (gets the pid of a process for use by subsequent commands)

Jmap-dump:format=b,file=xxx.hprof pid dump process memory usage into a file

Method 3: using jvisualVM

-use MAT tool to analyze:

Create a new folder (because many temporary files will be generated during analysis) and put in the .hprof files to be analyzed

Open MAT and select the .hprof file you want to analyze

During the analysis, follow the tips given by MAT step by step

Note:

Because the memory snapshot is instantaneous, it may need to be captured several times and analyzed many times before the problem can be found.

After the analysis, a compressed package will be generated. If you don't understand it, you can analyze it directly to the developer.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report