View JVM runtime heap memory with tools such as Jmap and Mat

Source: Internet
Author: User
Tags jconsole

Jmap

The JDK comes with some tools to help us see the heap memory running by the JVM, often with the jmap command

Jmap-heap <pid> Print Heap usage

Well, from this output we can also roughly see the structure of the heap, divided into young Generation (younger generation) and old Generation (older)

Young generation is also classified as: Eden space, from space and to space

You can see that the to area is clean and not yet in use, and the from zone has been used for 95%.

Jmap-histo[:live] <pid> Print the number of instances of the class, the memory used, the name of the class, usually we do not need to look at all, just look at the first few can

Jmap-dump:live,format=b,file=heap.bin <pid>

Use of dump heap in hprof binary format (PS: equivalent to generating a snapshot, we can analyze this snapshot file later)

Memory Analyzer (MAT)

After the file is dump, you can view it using Eclipse's Mat plugin

If you use Eclipse for daily development, you can install the plugin directly, and if not, the plugin can run independently.

www.eclipse.org/mat/

www.eclipse.org/mat/downloads.php

Double-click MemoryAnalyzer.exe to run after decompression

Open the Heap.bin file just now

You can see that there are three tabs below, including actions and reports that you can perform

Let's see the first one histogram .

Since this is a random project, there are no memory leaks and so on, so what we see here are some basic Java classes

View References

Dominator Tree can see the proportions of biggest object and the amount of memory they occupy

Our first-level search, you can find the source file, and then analyze the code, and ultimately locate the root cause of the problem

Jconsole

You can view a local process or a process on a remote host

Example: Jconsole 192.168.102.16:9105

or local

Other

Reference

78675960

Www.cnblogs.com/kongzhongqijing/articles/3621163.html

52460008

51874097

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.