Description
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:
- ReflectionUtils slow down application startup on WebSphere [SPR-11882] #16501 ReflectionUtils slow down application startup on WebSphere
- Make ReflectionUtils.doWithMethods work on Java 8 default interface methods [SPR-12822] #17419 Make ReflectionUtils.doWithMethods work on Java 8 default interface methods
- Reduce memory consumption for caches [SPR-13093] #17684 Reduce memory consumption for caches