RFR: 8308235: ThreadContainer registry accumulates weak refs [v2]

Alan Bateman alanb at openjdk.org
Mon May 22 06:20:59 UTC 2023


> ThreadContainers is an internal class used to make thread pools and other groupings of threads discoverable for observability. Some refactoring in 2021 (in the loom repo, and before integration) accidentally changed the creation of a weak reference so that it no longer associated with the reference queue. The result is that stale refs aren't expunged from a CHM, leading to a memory leak. The change to fix the issue is trivial.
> 
> Tests for memory leaks can be problematic, often more trouble than they are worth. I started with a test that polls the size of the internal CHM but decided to ditch it. Instead, the test is simple. It just runs for a few seconds creating ExecuorService implementations (including TPE, TPPE, and FJP), unreferencing them without shutdown (so they don't terminate and unregister). This is enough to causes OOME with product builds a small heap.

Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:

 - Change test to use nanoTime
 - Merge
 - Fix @run tag
 - Initial commit

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/14047/files
  - new: https://git.openjdk.org/jdk/pull/14047/files/89475604..562c6a1e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=14047&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14047&range=00-01

  Stats: 5024 lines in 169 files changed: 3826 ins; 371 del; 827 mod
  Patch: https://git.openjdk.org/jdk/pull/14047.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14047/head:pull/14047

PR: https://git.openjdk.org/jdk/pull/14047


More information about the core-libs-dev mailing list