Siva opened SPR-11612 and commented

We are noticing a memory leak and Spring objects loaded by system classloader are occupying 1.4 GB of memory.

"org.springframework.beans.factory.support.DefaultListableBeanFactory", loaded by "org.apache.catalina.loader.StandardClassLoader" occupy 1,493,680,816 (65.82%) bytes


Affects: 3.2.2

Attachments: - Dominator Tree.png (62.17 kB) - Dominator Tree 2.png (30.81 kB) - Histogram.png (10.09 kB)

3 votes, 9 watchers

Comment From: spring-projects-issues

Juergen Hoeller commented

A few general points:

  • What's the lifecycle of your your Spring ApplicationContexts / BeanFactory instances? How do you bootstrap and close them? Are multiple ClassLoaders involved?

  • We have done a lot of refinement work in memory management lately. Please upgrade to Spring Framework 3.2.8 at least and re-evaluate whether you see the same leak.

Juergen

Comment From: spring-projects-issues

liuylying commented

For Your Information ,You can look at this page: http://daheyuan.blog.51cto.com/6365745/1139358

Comment From: spring-projects-issues

Siddharth Sharma commented

Hi,

We faced similar issue after upgrading to 3.2.8 from 3.2.3. Looking at heap dump, around 2.5gb of old generation was occupied by DefaultListableBeanFactory. Most of the prototype beans weren't garbage collected.

-Sid

Comment From: spring-projects-issues

Guru commented

Hi, We are using springs 3.0.5 and we are due to upgrade to 3.2.x versions in our high performance applications, but while profiling saw that big objects list contains mainly DefaultListableBeanFactory, which version of springs will remove this issue. as there is huge memory occupied by this class for each bean creation.

thanks for your support.

Comment From: spring-projects-issues

Matthias Müller commented

Hi, maybe this bug is related to #16145 which was fixed in 3.2.9, so is still present in the 3.2.8?? Is the error still present with 3.2.9?

Regards Matthias

Comment From: spring-projects-issues

Eduardo Simioni commented

I have this problem, or a similar one with version 4.1.6.RELEASE.

What I see is that the class loaders are not being release when redeploying and the bulk of what the hold is Spring related. I'm not sure if it is a Spring problem, or if something else is preventing the class loaders from being garbage collected, and it is normal that the class loader holds a lot of Spring objects.

Using Tomcat, I fixed all problems that it used to report while redeploying, still this issue persists.

Eduardo.

Comment From: spring-projects-issues

Eduardo Simioni commented

Forget about the problem I've posted earlier.

In my case it was related to JDBC4 driver (residing on WEB-INF/lib) not being deregistered on application shutdown/reload. Although Tomcat would not report any problem on redeployment, or, depending on the environment, report "forcibly deregistering to prevent memory leak", the leak would still occur.

I'd guess that the fact that org.apache.catalina.loader.WebappClassLoader is holding a lot of Spring objects is just normal then, since my application is heavily based on Spring, and now those objects can be garbage collected with the classloader altogether.

Hope this might help someone.

Eduardo.

Comment From: spring-projects-issues

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Comment From: hassibnkhoury

so what is the solution? i am using the latest version of spring boot 3.2.1 and still the issue of memory appears: One instance of “org.springframework.beans.factory.support.DefaultListableBeanFactory” loaded by “org.springframework.boot.loader.launch.LaunchedClassLoader @ 0xf006e300” occupies 1,025,792 (11.57%) bytes. The memory is accumulated in one instance of “org.springframework.beans.factory.support.DefaultListableBeanFactory”, loaded by “org.springframework.boot.loader.launch.LaunchedClassLoader @ 0xf006e300”, which occupies 1,025,792 (11.57%) bytes.

Keywords org.springframework.beans.factory.support.DefaultListableBeanFactory org.springframework.boot.loader.launch.LaunchedClassLoader