
1、java.lang.StackOverflowError

2、java.lang.OutOfMemoryError:java heap space

3、java.lang.OutOfMemoryError:GC overhead limit exceeded


4、java.lang.OutOfMemoryError:Direct buffer memory


5、java.lang.OutOfMemoryError:unable to create new native thread

6、java.lang.OutOfMemoryError:Metaspace

import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;
import java.lang.reflect.Method;
public class MetaspaceOOMTest {
static class OOMTest { }
public static void main(String[] args) throws InterruptedException {
int i = 0;
try {
while (true) {
i++;
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(OOMTest.class);
enhancer.setUseCache(false);
enhancer.setCallback(new MethodInterceptor() {
@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
return methodProxy.invokeSuper(o, args);
}
});
enhancer.create();
}
} catch (Throwable e) {
System.out.println("*****第 i:" + i + " 次后发生异常!");
e.printStackTrace();
}
}
}
