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

ReflectionUtils cache uses up a fairly big chunk of heap even [SPR-13783] #18357

Closed
spring-issuemaster opened this issue Dec 9, 2015 · 2 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Dec 9, 2015

Dave Syer opened SPR-13783 and commented

I noticed in a memory constrained application (simple Spring Boot app with -Xmx32m) I was seeing a lot of ReflectionUtils in the YourKit "biggest objects" list, and drilling down into it reveals a couple of references to caches. They look like they are designed to be garbage collected, but apparently they are not. The app was sitting happily at 23MB heap, but I wanted to see if I could do better, so I added reflective hack calls to clear the two caches in ReflectionUtils and miraculously the heap shrank (after GC) down to about 14MB, and was stable from there even nuder load. I feel maybe this merits clearing the cache at least optionally in the startup phase of an app, either in Spring or in Boot (where we could make it optional for low memory apps).


Affects: 4.2.3

Issue Links:

  • #16501 ReflectionUtils slow down application startup on WebSphere
  • #17419 Make ReflectionUtils.doWithMethods work on Java 8 default interface methods
  • #17684 Reduce memory consumption for caches
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 9, 2015

Juergen Hoeller commented

I've added a ReflectionUtils.clearCache() method, triggered by AbstractApplicationContext.clearCommonCaches() now. To be pushed in just a bit...

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 9, 2015

Dave Syer commented

Update: I no longer believe the effect is as dramatic as I thought (the 23-14 range is peak-before to trough-after). But it's definitely real. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.