jmap

The JDK comes with tools to help you see how much heap memory the JVM is running. The most common is the jmap command

Jmap-heap prints heap usage

So, from this output, we can also see the structure of the heap, which is divided into Young Generation and Old Generation.

Young Generation is divided into Eden Space, From Space and To Space

As you can see here, the To area is clean and unused, and the From area is 95% used

Jmap-histo [:live] prints the number of instances of the class, the memory used, the name of the class, and usually we don’t need to see all of them, just the first few

jmap -dump:live,format=b,file=heap.bin

Dump heap usage in hprof binary format (PS: generates a snapshot file that can be analyzed later)

Memory Analyzer (MAT)

After the file is dumped, you can use the Eclipse MAT plug-in to view it

If you use Eclipse for your daily development, you can install the plug-in directly, or if you don’t, the plug-in can run independently

www.eclipse.org/mat/

www.eclipse.org/mat/downloa…

To run, double-click MemoryAnalyzer.exe after decompression

Open the heap.bin file

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

Look at the first Histogram first

Since this is a random project, there are no memory leaks or anything like that, so what you see here are some basic Java classes

See the reference

The Dominator Tree can see the biggest object and what percentage of memory they occupy

We can go level by level, find the source file, analyze the code, and finally locate the root of the problem

jconsole

You can view local processes as well as processes on remote hosts

For example, jConsole 192.168.102.16:9105

Or the local

other

reference

Blog.csdn.net/xiaojia1100…

www.cnblogs.com/kongzhongqi…

Blog.csdn.net/alli0968/ar…

Blog.csdn.net/u011512180/…

Author: waste big brother source: www.cnblogs.com/cjsblog/p/9…

Some interview questions for 2020 are summarized. The interview questions are divided into 19 modules, which are: Java Basics, Containers, multithreading, reflection, object copy, Java Web, exceptions, Networking, Design patterns, Spring/Spring MVC, Spring Boot/Spring Cloud, Hibernate, MyBatis, RabbitMQ, Kafka, Zookeeper, MySQL, Redis, JVM.

Access to information above information: concern public number: programmers with stories, access to learning materials. Remember to click follow + comment oh ~