PermGen leak
feng l.liu
feng.l.liu at oracle.com
Mon Jul 8 06:35:22 UTC 2013
Hello Experts,
I am building up a test tool with ant, but I encountered so many
DelegatingClassLoaders that put pressures on PermGen. I know that
DelegatingClassLoaders are caused by java reflection.
Google search show some posts indicating generation of
DelegatingClassLoader will be depressed if
sun.reflect.inflationThreshold to zero , I tried it and found that this
idea did not work at all. I dived into the code and found the snippets
as below:
It looks that the DelegatingClassLoader will go away if I set
sun.reflect.noInflation = true and sun.reflect.inflationThreshold to
Integer.MAX_VALUE. I tried it again but this idea did not work as well.
can you please give me some advices on this leak?
thank you in advance
ReflectionFactory.java
String val =
System.getProperty("sun.reflect.noInflation");
if (val != null && val.equals("true")) {
noInflation = true;
}
val =
System.getProperty("sun.reflect.inflationThreshold");
if (val != null) {
try {
inflationThreshold = Integer.parseInt(val);
} catch (NumberFormatException e) {
throw (RuntimeException)
new RuntimeException("Unable to parse
property sun.reflect.inflationThreshold").
initCause(e);
}
}
initted = true;
return null;
}
NativeMethodAccessorImpl.java
public Object invoke(Object obj, Object[] args)
throws IllegalArgumentException, InvocationTargetException
{
if (++numInvocations > ReflectionFactory.inflationThreshold()) {
MethodAccessorImpl acc = (MethodAccessorImpl)
new MethodAccessorGenerator().
generateMethod(method.getDeclaringClass(),
method.getName(),
method.getParameterTypes(),
method.getReturnType(),
method.getExceptionTypes(),
method.getModifiers());
parent.setDelegate(acc);
}
return invoke0(method, obj, args);
}
Best regards
More information about the core-libs-dev
mailing list