代码实现java8元空间溢出
public class UserController {
Logger logger= LoggerFactory.getLogger(UserController.class);
private ThreadService threadService;
public String TEST(){
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(User.class);
enhancer.setUseCache(false);
enhancer.setCallback(new MethodInterceptor() {
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
return proxy.invoke(obj, args);
}
});
Object o=enhancer.create();
System.out.println(o.toString());
User user=threadService.getUser();
logger.info(user.toString());
user.setUserName("1");
return "success";
}
}
评论