RFR: 8260621: Avoid memory leak in ImageBufferCache

Bo Zhang github.com+12689835+blindpirate at openjdk.java.net
Wed Feb 3 00:52:59 UTC 2021


Previously, `ImageBufferCache` contains a ThreadLocal field which holds
strong reference to `ImageBufferCache$BufferReference.class`. When loaded
from `jrt-fs.jar`, this will keep `JrtFileSystemProvider$JrtFsLoader`
in memory forever and never being GCed.

The fix replace the old `ImageBufferCache$BufferReference` class with
`WeakReference<ByteBuffer>`, which is verified by provided test.

-------------

Commit messages:
 - 8260621: Avoid memory leak in ImageBufferCache

Changes: https://git.openjdk.java.net/jdk/pull/2307/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2307&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8260621
  Stats: 123 lines in 2 files changed: 75 ins; 23 del; 25 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2307.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2307/head:pull/2307

PR: https://git.openjdk.java.net/jdk/pull/2307


More information about the core-libs-dev mailing list