Useadaptivesizepolicy JVM error caused by concurrent use with CMS garbage collection

Source: Internet
Author: User

When the system changes in the grayscale environment, the JVM startup error is detected, the JVM configuration parameters are checked in detail, and the following configuration is found in the new realm:

-xx:+useadaptivesizepolicy and-XX:+USECONCMARKSWEEPGC

The initial conjecture is a problem with the configuration of the JVM parameters, so the system stack usage is viewed through JMAP-HEAP, as follows:

Heap Configuration:     minheapfreeratio =     maxheapfreeratio =     maxheapsize      = 10737418240 (10240.0MB)     NewSize          = 2147483648 (2048.0MB)     maxnewsize       = 2147483648 (2048.0MB)     oldsize          = 5439488 ( 5.1875MB)     Newratio         = 2     survivorratio    = 4     permsize         = 21757952 (20.75MB)     MaxPermSize      = 134217728 (128.0MB)  Heap Usage:  unknown Generation type:     capacity = 0 (0.0MB)     Used     = 0 (0.0MB)     free     = 0 (0.0MB)     nan% used  unknown generation type:     capacity = 0 (0.0MB) c28/>used     = 0 (0.0MB)     free     = 0 (0.0MB)     nan% used  Perm Generation:     capacity = 60878848 ( 58.05859375MB)     Used     = 37927152 (36.17015075683594MB)     free     = 22951696 (21.888442993164062MB)     

Find an exception from the printed stack information

First, the JVM analysis

1. Source View

The Management.cpp code of the JDK was analyzed, and the commit was accumulated when calculating the size of the heap memory area, but in the case where max_size was not defined (invalid, obtained from MemoryPool), Total_max did not accumulate, Cause commited to be larger than Max.

Post-repair code see: http://hg.openjdk.java.net/hsx/hsx25/hotspot/file/a70566600baf/src/share/vm/services/ The method of Management.cpp is jvm_entry.

Contrast:
Originally only processed:

if (!has_undefined_max_size) {    Total_max + = U.max_size ();  }  

How to fix the problem: Adding code handling does not define INIT and Max conditions

if (has_undefined_init_size) {       total_init = (size_t)-1;    }  if (has_undefined_max_size) {        Total_max = (size_t)-1;    }  


2, Jmap can not get data reasons

Jmap causes: (Useadaptivesizepolicy + CMS will appear at the same time) (the condition Source: Sun/jvm/hotspot/memory/generationfactory.java):

try {       return (Generation) ctor.instantiatewrapperfor (addr),  } catch (Wrongtypeexception e) {       return new Generation (addr) {public       String name () {       return ' unknown Generation type ';  ......  

Second, the cause of the problem

The current confirmation is the JVM bug, the initial confirmation version is more than 1.6_u30, including 1.7, there is this problem. jdk6.30 The following versions have not been confirmed (after using the 1.6_U25 version, there is no recurring problem)--- 1.6.30 above to 1.7 all versions have confirmed this issue, JDK8 repair, other versions to be verified

Brief cause analysis See: http://blog.csdn.net/axman/article/details/8667351

Using the CMS algorithm, if the parameter useadaptivesizepolicy is turned on, the size of eden,from and to is recalculated each time the GC is minor, and the calculation process is based on some data from GC process statistics, and the calculated eden+from+ To does not exceed xmx, and the From and to are generally unequal (when initialized from and to are equal). The main problem is that after the calculation, if Eden gets larger, the max_eden_size in the Contiguousspacepool is not updated or the value at the beginning, which results in the JVM passing the Call_ Special calls Java.lang.management. Memoryusage's constructor generates exception, exception is caused by the committed of Eden greater than the max_size of Eden, Causes the returned java.lang.management. Memoryusage object to fail, resulting in a display exception.

Iii. Solutions

You can set the version of –xx:-useadaptivesizepolicy to WORKAROUND,JDK first: The version of the Sun JDK after the problem is currently only jdk8 repaired; OPENJDK is a hs25 fix.

Useadaptivesizepolicy JVM error caused by concurrent use with CMS garbage collection

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.