Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoutering memory issues post Spring boot 2.7.1 version #32071

Closed
loveshjain opened this issue Aug 12, 2022 · 13 comments
Closed

Encoutering memory issues post Spring boot 2.7.1 version #32071

loveshjain opened this issue Aug 12, 2022 · 13 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@loveshjain
Copy link

loveshjain commented Aug 12, 2022

After upgrading our applications to Spring boot 2.7.1 version, we have started encountering memory issues.

Our Observations

Changes were made in 2.7.1 in the org.springframework.boot.loader.jar package around closing jar files. A list of nested jars were added and that is what is holding on to objects in our heap dump.

We can see 22,000 JarFile objects in the heap dump where we'd expect about 118 as that is how many nested jars there are in the application. Note that apart from the expected jar files, the other 22,000-odd are all url = jar:file:/deployments/application-web-1.0.0.jar!/BOOT-INF/lib/swagger-ui-4.11.1.jar!/

Please find below the heap dump and Dynatrace screenshot as reference

image

image

Note :- No changes were made in org.springframework.boot.loader.jar package in 2.7.2 so I suspect the problem will still be there.

Can someone please look into this.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 12, 2022
@wilkinsona
Copy link
Member

Thanks for the report, @loveshjain. There are some similarities with #32042 and #31853. Are you using PropertiesLauncher to run your app? To allow us to diagnose the problem, please provide a minimal sample that reproduces the leak.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Aug 15, 2022
@philwebb philwebb self-assigned this Aug 15, 2022
@philwebb
Copy link
Member

@loveshjain I've pushed a fix for #31853 that removes the nested jars list. Once build 713 could you please try the latest SNAPSHOT and see if the memory issues persist?

@beggsj42
Copy link

Hi @philwebb - I work with @loveshjain and am looking at this. Our problem is that we haven't been able to replicate this in non-prod. I'm going to see what I can do in that regard in the next couple of days.

I'm speculating that this might have to do with the JarFile objects being removed by the GC (as they are soft referenced?) if there is memory pressure, and then being reloaded later, but never getting removed from the nested jars list? I've never really looked at custom class loader code though so I'm a bit in the dark.
Does that sound reasonable though - to maybe try to get the JVM close to the heap limit and see if that causes it? I'm just looking for things to try really.

It was fairly odd behaviour in production - it went for several days without us noticing an issue, and when we did hit the issue it wasn't in a high-load period and it seemed to self-correct. In the tenured gen picture above it looks like it started to have a GC issue about 10am, but we didn't notice until it started affecting response time badly at about 9:45pm.

We have had similar issues on multiple services though and rolling back to 2.7.0 resolved it.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 17, 2022
@beggsj42
Copy link

I believe we're using the JarLauncher - we're just using the spring-boot-maven-plugin and we're not overriding the 'layout'.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Aug 17, 2022
@philwebb
Copy link
Member

See #31853 (comment). We're going to revert #29356

@beggsj42
Copy link

Right, thanks - I'm fairly sure that will solve our issue. I'll still try to put some effort in to replicating the problem though hopefully it'll mostly just be for the intellectual exercise now.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 18, 2022
@snicoll
Copy link
Member

snicoll commented Aug 19, 2022

@beggsj42 upgrading to 2.7.3 contains the change that Phil mentioned if you want to double check.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Sep 3, 2022
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Sep 10, 2022
@beggsj42
Copy link

Sorry for the late reply. I still haven't been able to replicate the problem in 2.7.1 in non-prod, but 2.7.3 definitely has solved the issue for us in production.

We're happy for this issue to be closed, thanks.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Sep 11, 2022
@snicoll
Copy link
Member

snicoll commented Sep 12, 2022

Thanks for following up.

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2022
@snicoll snicoll added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Sep 12, 2022
@sm0217
Copy link

sm0217 commented Nov 3, 2023

Apologies for commenting on a closed ticket but we are seeing similar issues upgrading from 2.4 to 2.7.16. May I know if there was any fix provided for this and it is present in the latest 2.7.x versions

@wilkinsona
Copy link
Member

Please see above. A change was made in Spring Boot 2.7.3 that fixed the problem that was reported in this issue. That fix has not be removed and should be present in the latest 2.7.x versions.

@sushmitha-malae
Copy link

Hi @sm0217 Were you able to fix the issues? we are also facing similar issues when upgraded to 2.7.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

8 participants