Description
our team has a memory leak problem lately.
I have dump the heap and found that there are many strings in the heap. the strings is something about redirect string. So we reproduce the problem by the following demo project: https://github.com/zhao41654828/springstudy/tree/master/service-hi
controller adress: https://github.com/zhao41654828/springstudy/blob/master/service-hi/src/main/java/com/forezp/web/MiniProgramController.java
Debug the program by sending a request:127.0.0.1:8763/web/testRedirect1
we can find that it run into like this:
In the AbstractAutoProxyCreator class, the advisedBeans don't have number limit, the ConcurrentHashMap will have a lot of objects.
I want to know this is whether or not a bug in springmvc. If not, I want to know the reason and how can I to avoid it.
Now i do like this to avoid it.
/**
* @param
* @return
*/
@RequestMapping("/testRedirect1")
public void getTest2(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String redirectUrl = "http://www.baidu.com";
Random random = new Random();
int data = random.nextInt(21_0000_0000);
redirectUrl = redirectUrl + "/" + data;
resp.sendRedirect(redirectUrl);
}