Search code examples
javaspringspring-mvcmemory-leaksmemory-leak-detector

Memory leak in jboss service due to DefaultListableBeanFactory objects


In my jboss service, I get memory leak. I checked the heap dump, I saw the major portion of heap is occupied by DefaultListableBeanFactory and ConcurrentHashMap.

I came across this issue reported already, https://jira.spring.io/browse/SPR-9842

My issue is also the same but I use spring(spring-beans) version 3.1.1.RELEASE. Can somebody help if this is actually a problem with spring or is it a problem with my code? Also if it is a problem with the spring, what is the solution?

Thanks


Solution

  • I found out the cause of the problem. The issue was that, in the code ClassPathXmlApplicationContext object is instantiated for each request.

    I changed the ClassPathXmlApplicationContext object to static and now I no longer face this problem. Thanks for the support.

    The comment in the link explained the problem, https://jira.spring.io/browse/SPR-7502?focusedCommentId=57240&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-57240