Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid GeneratedSerializationConstructorAccessor problems?

We have a Java App that receives SOAP requests, and after a lot of requests we notice that the GC stops the world to unload a lot of GeneratedSerializationConstructorAccessor classes. This is a big performance impact.

Does anyone know how to avoid this or at least significantly reduce the count of GeneratedSerializationConstructorAccessor classes created?

like image 810
james Avatar asked Jun 04 '10 01:06

james


2 Answers

Use one of the options:

-Dsun.reflect.inflationThreshold=30

Increases the number of calls through a Constructor/Method/Field before a native accessor will be "inflated" to a generated accessor. The default is 15.

-Dsun.reflect.inflationThreshold=0

Disables inflation altogether. Interestingly, this option does not seem to affect constructors, but it does work for methods.

You can test the options with a simple test app:

public class a {
  public static void main(String[] args) throws Exception {
    for (int i = 0; i < 20; i++) {
      a.class.getDeclaredConstructor(null).newInstance(null);
    }
  }

  private static int x;
  public a() {
    new Throwable("" + x++).printStackTrace();
  }
}

Edit (29-Dec-2013): The -Dsun.reflect.noInflation=true option disables the inflation mechanism and instead immediately uses generated accessors, so you don't want that option.

like image 180
Brett Kail Avatar answered Nov 14 '22 22:11

Brett Kail


[...] we notice that the GC stops the world to unload a lot of GeneratedSerializationConstructorAccessor classes. This is a big performance impact.

As it is impossible to avoid if your application is using reflection, you may try using CMS garbage collector to minimize the impact of the stop-the-world GC.

like image 27
fglez Avatar answered Nov 14 '22 22:11

fglez