Using Memory Analyzer under Linux

Source: Internet
Author: User
Tags install window

I. Installing the memory Analyzer Tool

Open Eclipse >> help >> Install New software >> Click the Add on the right side of work, enter

[Name]  Mat[location]  http://archive.eclipse.org/mat/1.2/update-site/  

Click OK >> Click Select All under the Install window, then continue to the next step until the end.

Two. Using Memory Analyzer

Create a Java project (just one Class), Code (class name Oomobject)

1 Importjava.util.ArrayList;2 Importjava.util.List;3 4 /**5 * Created by Foreverenjoy on 16-7-9.6  */7  Public classHeapoom {8     Static classOomobject {9 Ten     } One  A      Public Static voidMain (string[] args) { -list<oomobject> list =NewArraylist<>(); -  the          while(true) { -List.add (Newoomobject ()); -         } -     } +}
JAVA Code

To set the VM parameters in debug cofigurations:

-xms20m-xmx20m-xx:+heapdumponoutofmemoryerror

The parameter-xx:+heapdumponoutofmemoryerror allows the virtual machine to dump the current memory heap dump snapshot for post-mortem analysis when a memory overflow exception occurs.

Click Debug to run the project, which will appear

java_pid17179.hprof ... Heap dump file created [27535550 bytes in 0.099 secs]

The java_pid17179.hprof (VM dump snapshot) file can be analyzed using the memory Analyzer tool.

Click File >> Open file >> Select Java_pid17179.hprof (java_*.hprof) Under this Java project >> check leak suspecs report >> F Inish

The following is the analysis of Memory analyzer

Using Memory Analyzer under Linux

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.