Four common anomalies in Java JVM and their handling schemes

Source: Internet
Author: User

Regional Role Abnormal Control parameters Solution Ideas
Java heap Holds an instance of an object. Java.lang.OutOfMemory Error:java Heap Space

-xms (Initialize heap),

-XMX (Max Heap),

-xmn (Cenozoic)

1, first check whether the memory leak (the object in memory is not required), if it is a leak, find the path with GC ROOT to resolve the leak.

2, see whether the physical memory is allowed to increase-xms,-xmx.

3. Check whether there are object instances in the heap that have not been released in memory.

4, the technique lets-xms =-xmx, reduces the memory expansion the overhead.

Virtual machine stack and local method stack Control the execution of the method.

If the thread requests a stack depth that is greater than the maximum allowed depth for the virtual machine: Java.lang.StackOverflow Error

If you are not able to request enough memory space in the sequel to the extension stack:

Java.lang.OUtOfMemory Error

-xss

1, increase the-XSS parameter.

2, reduce the thread.

3. Replace the 64-bit virtual machine.

4, reduce the maximum heap (XMX).

Method area Information about classes such as class names, access modifiers, Chang, field descriptions, method descriptions, and so on. Java. OutOfMemory Error:permgen Space

-xx:permsize

-xx:maxpermsize

This is the most common memory overflow exception.

1, increase the parameters (temporary cure).

2, add Parameters:-xx:printgcdetails,-xx:+printgctimestamps and-xx:+printgcdatestamps, you can also specify the log output to the file:-xloggc:<filename>. View the GC logs to see the recovery efficiency and recovery frequency of the new generation GC (Minor GC) and the old age GC (full GC or MAJORGC). Usually minor GC will be very frequent, recycling efficiency is high is right.

3, slightly increase the space of Survivor1 Survivor2.

Native Direct Memory such as NIO, is directly through this memory implementation.

Java.lang.OutOfMemory Error, there

Allocate, native words

-maxdirectmemorysize

If not specified, it is consistent with-XMX.

Plan server memory reasonably, reserving enough memory for local memory. Increase the parameters.

Spatial relationship:

Java heap = new Generation + old age.

Cenozoic = Eden (Eden) + Survivor1 + Survivor2.

In most cases, objects are allocated in the Cenozoic Eden region. When there is not enough space in Eden, the minor GC is triggered once. Survivor2 is used for replication when the minor GC is in use. When the minor GC occurs, if it is found that the object to be assisted (the Living object) cannot be stored in the Survivor2, it is transferred to the old age in advance by the allocation guarantee mechanism.

such as configuring-xms20m,-xmx20m,-xmn10m,-xx:survivorratio=8.

Meaning: Java heap size is 20M, not extensible, where 10MB allocated to the new generation, the remaining 10MB points to the old age. -xx:survivorratio=8 indicates that the space ratio between Eden in the Cenozoic and one of the survivor areas is 8:1. That is, Eden space 8192k,from space 1024k,to space 1024k. The total free space for the new generation is 9216kb (total of Eden Zone + 1 survivor area).

Copyright NOTICE: This article only author original, turn please indicate the source.

Four common anomalies in Java JVM and their handling schemes

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.