Integrated: 8277072: ObjectStreamClass caches keep ClassLoaders alive
Roman Kennke
rkennke at openjdk.java.net
Fri Dec 10 16:27:19 UTC 2021
On Fri, 12 Nov 2021 21:43:42 GMT, Roman Kennke <rkennke at openjdk.org> wrote:
> The caches in ObjectStreamClass basically map WeakReference<Class> to SoftReference<ObjectStreamClass>, where the ObjectStreamClass also references the same Class. That means that the cache entry, and thus the class and its class-loader, will not get reclaimed, unless the GC determines that memory pressure is very high.
>
> However, this seems bogus, because that unnecessarily keeps ClassLoaders and all its classes alive much longer than necessary: as soon as a ClassLoader (and all its classes) become unreachable, there is no point in retaining the stuff in OSC's caches.
>
> The proposed change is to use WeakReference instead of SoftReference for the values in caches.
>
> Testing:
> - [x] tier1
> - [x] tier2
> - [x] tier3
> - [ ] tier4
This pull request has now been integrated.
Changeset: 8eb453ba
Author: Roman Kennke <rkennke at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/8eb453baebe377697286f7eb32280ca9f1fd7775
Stats: 496 lines in 4 files changed: 284 ins; 186 del; 26 mod
8277072: ObjectStreamClass caches keep ClassLoaders alive
Reviewed-by: rriggs, plevart
-------------
PR: https://git.openjdk.java.net/jdk/pull/6375
More information about the core-libs-dev
mailing list