Actual combat Java Virtual machine JVM fault diagnosis and performance optimization (vii)

Source: Internet
Author: User

Analyzing the Java heap 1. Remedy: Find the cause of memory overflow

Memory overflow (OutofMemory, or Oom), which focuses on the most common centralized memory overflow issues, including heap overflow, direct memory overflow, persistent zone overflow, and so on.

Heap Overflow

Overflow occurs when the sum of the object size is greater than the amount of heap space specified by the XMX parameter.

Direct Memory Overflow

In the Java NiO (new IO), the use of direct memory is supported, and the memory outside the heap is applied directly to the operating system.

Over-threading leads to Oom

Because the thread's stack space is also allocated outside the heap.

Permanent Zone Overflow

The area where the metadata of the class is stored, and if a system defines too many classes, the permanent zone overflows. However, in jdk1.8, the permanent zone is replaced by a block called the metadata region, but the function is similar, all to preserve the meta-information of the class.

Virtual machine endoscope: Analyzing Java heap using mat

1. What is Mat?

MAT, a Memory analyzer tool, is a fast, feature-rich Java heap Analysis tool that helps us to find memory leaks and reduce memory consumption. Use the Memory analysis tool to analyze from a multitude of objects to quickly calculate the size of objects in memory, to see who is preventing the garbage collector from recycling, and to visually look at the objects that may be causing the results through the report.

2. Why use Mat?
When a server application consumes too much memory, it encounters OutOfMemoryError. How to quickly locate the problem? The advent of Eclipse mat made the problem very simple. It is able to analyze dump file data offline.
Eclipse Mat is a tool that SAP has contributed to, and can be downloaded to it on the Eclipse website, completely free of charge. It's a lot stronger than the Jhat memory image analysis tool that Sun provides.
3. Address
Home:http://www.eclipse.org/mat/
Plugin Update Address:
http://download.eclipse.org/mat/1.0/update-site/

Note: You can use the Jmap command to make a heap of snapshots, using release: http://www.cnblogs.com/kaishi/p/7515216.html

File---> Acquire Heap Dump open a running program, or open a dump file

To view memory usage:

View Class Bar chart

To view a reference relationship:

You can find objects referencing the current object by using the mat, which refers to the object referenced with incoming references, which already references the current object.

Shallow heaps and deep heaps

The shallow heap (shallow heap) and the deep heap (retained heap) are two very important concepts that represent the size of an object's structure in memory and the amount of memory that an object can actually release after being recycled by GC.

Tomcat Heap Overflow Analysis

Thought: Analyze the dump file, select a large chunk of Jian memory, make reference tracking, find objects in the heap memory that occur frequently

  

Actual combat Java Virtual machine JVM fault diagnosis and performance optimization (vii)

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.