Accessories 3:eclipse Memory Analyze Use tutorial

Source: Internet
Author: User

Http://jingyan.baidu.com/article/ce09321b620a3d2bff858ff5.html

Simple to use:

Analysis of three-step curve:

Usually we use the following "three steps" to analyze the memory leak problem:

First, get an overall impression of the system memory state at the time the problem occurred.

The second step is to find the culprit that is most likely to cause a memory leak, usually the object that consumes the most memory

Next, take a closer look at the specifics of this large memory consumer and see if there are any unusual behaviors.

The following is a basic example of how to use the "three steps" to view production analysis reports.

1. View one of the reports: Overall status of memory consumption

The most striking thing on the report is a simple pie chart, from which we can see clearly that a suspicious object consumes 99% of the system's memory.

A further description of this suspicious object is also available below the graph. We can see that the memory is consumed by the Java.util.Vector instance, and Com.ibm.oti.vm.BootstrapClassLoader is responsible for loading the object. This description is very short, but I'm sure you can find a lot of clues, such as which class takes up most of the memory, which component it belongs to, and so on.

Next, we should go further to analyze the problem, why a Vector will occupy the system 99% of the memory, who stopped the garbage collection mechanism of its recycling.

    1. View report Two: Analyzing the problem

First, we briefly review the JAVA memory recycling mechanism, the garbage collection in memory space is done by the garbage collector (garbage COLLECTOR,GC), its core idea is: the virtual machine available memory space, that is, the object in the heap space, if the object is being referenced, It is then called a surviving object, and conversely, if the object is no longer referenced, it is a garbage object that can reclaim its occupied space for redistribution.

In the garbage collection mechanism, a set of elements is called the root element collection, which is a set of objects that are directly referenced by the virtual machine, such as the running thread object, the objects inside the system call stack, and the objects that are loaded by the Systems class loader. Each object in the heap space is called by a root element as the starting point for the layer. Therefore, an object is also referenced by a surviving root element, which is considered to be a surviving object and cannot be reclaimed for memory release. Therefore, we can parse the reference path of an object to the root element to analyze why the object cannot be reclaimed successfully. If an object is not required by any program logic but there is a case where the root element is referenced, we can say there is a memory leak.

Now, let's really look for a memory leak tour and click on the "Details" link to see a detailed analysis of the suspicious object 1 shown in 8.

    1. We look at the shortest path from the GC root element to the memory consumption aggregation point: we can clearly see the entire reference chain, the memory aggregation point is a collection of a large number of objects, if you are familiar with the code, believe that this information should provide you with some ideas to find a memory leak.

    1. Next, let's take a look at what's in this object collection and why it consumes so much memory. In this diagram, we can see clearly that this object collection holds a large number of references to the person object, which is the memory leak that it causes.

Https://wenku.baidu.com/view/bc5b6b8dcaaedd3382c4d3c8.html

Detailed Tutorials:

1. Heap Dump

Example:

Heap dump is a snapshot of the memory of a Java process at a point in time. Heap dump is in many formats. In general, however, heap dump stores information about Java objects and classes when it triggers a snapshot. Typically, a FULLGC is triggered before the heap dump file is written, so the heap dump file holds the object information left after FULLGC.

Memory Analyzer can be used to process hprof binary heap dump files, IBM System dump files (after processing), and IBM Portable Heap dumps (PHD) files from various platforms.

It is generally available in the heap dump file (which still depends on the type of heap dump file) as in the following information:

Object information: class, member variable, direct volume, and reference value;

Class information: Class loader, name, superclass, static member;

Garbage collections ROOTS:JVM to reach the object;

Line stacks and local variables: the thread stack information at the time the snapshot was taken, and the details of the local variables.

The heap dump file does not contain memory allocation information, so problems with WHO and where to create objects are usually not resolved through the heap dump file.


Accessories 3:eclipse Memory Analyze Use tutorial

Related Article

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.