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?
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.
[...] 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With