MyEclipse installs the Eclipse Memory Analyzer plug-in and makes error file analysis processes __JVM

Source: Internet
Author: User
Transferred from Http://www.cnblogs.com/nb44c/p/5218880.html

Looking deep into the JVM virtual machine book (p50,2.4 combat OutOfMemoryError), there is an example of a Java heap overflow, using the Eclipse Memory Analyzer plug-in, because it is now using MyEclipse, So you need to add plug-ins on the MyEclipse. The concrete steps are as follows: 1. Install the mat plugin first

Memory Analyzer plugin Download Address: http://www.eclipse.org/mat/downloads.php

Click to download

3. Extract the downloaded files to the MyEclipse Dropins folder

4. Create a. link file with the same name as the folder, where the contents of the file are written with the corresponding address (address using \ or/)

5. Restart MyEclipse, you can see the Memory Analyzer option in window---->preferances.

2. using the Mat tool for analyzing instances

1. Create test Java code

/**
 

-verbose:gc-xms20m-xmx20m
-xx:+heapdumponoutofmemoryerror

 * @author y
 * * *
/public class Test {

    static class oomobject{
        
    } public
    
    static void Main (string[] A RGS) {
        list<oomobject> List = new arraylist<oomobject> ();
        
        while (true) {
            list.add (new Oomobject ());}}}
   

2. Set Run parameters

Explain the meaning of the parameter:

The 1.JAVA-VERBOSE:GC parameter-VERBOSE:GC represents the details of the GC in the output virtual machine.

After use, the output is as follows:

[Full GC 168k->97k (1984K), 0.0253873 secs]

Read as follows:

The data 168K and 97K before and after the arrows represent the amount of memory used by all surviving objects before and after GC, indicating that the 168k-97k=71k object capacity is reclaimed, and the data in parentheses is 1984K of the total capacity of the heap memory, The time required for collection is 0.0253873 seconds (this time will vary at each execution)

NOTE:GC will take up CPU time slices, which may cause the application to pause for a very short period of time.

2.-XMS: Sets the minimum value of the heap, –xmx: Sets the maximum value of the heap

Set them to 20M here, to avoid automatic heap expansion.

3. Parameter –xx:+heapdumponoutofmemoryerror allows the virtual machine to dump the current memory heap dump snapshot in case of a memory overflow exception for subsequent analysis.

3. Run the program, the following information will appear

At this point, we can find the corresponding file in the root of the project, and then we can use the heap dump snapshot from the mat tool to analyze it.

3. Conduct Analysis

1. Open the heap dump snapshot directly through OpenFile

2. The specific analysis refers to the following links:

http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-ma/index.html?ca=drs-

http://essen.iteye.com/blog/1825314

http://tivan.iteye.com/blog/1487855

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.