RFR: 8304436: com/sun/jdi/ThreadMemoryLeakTest.java fails with "OutOfMemoryError: Java heap space" with ZGC

Chris Plummer cjplummer at openjdk.org
Tue Mar 21 21:47:37 UTC 2023


There are two GC related issues with this test that are being addressed. The test was limiting the heap size to 6m so if there is still a leak, it will be detected quickly. This proved to be too small of a size when using ZGC. For the most part changing the size to 7m fixed this issue. However, I was still seeing frequent issues with ZGC on macOS. This is explained by [JDK-8304449](https://bugs.openjdk.org/browse/JDK-8304449), which noticed (rarely) OOME on macos even when not using ZGC. From JDK-8304449:

"macOS has a thread behavior that is not seen on linux and windows that is causing more memory usage, which sometimes leads to this unexpected OOME. The debuggee side of the test constantly creates threads that do little more than a short sleep. It has a counter of "live" threads, and won't let that go over 500. On the debugger side it is just tracking ThreadStartEvents and ThreadDeathEvents. It keep tracks of threads (ThreadReferences) for which a ThreadStartEvent had been received but a ThreadDeathEvent has not. On linux and windows the count of outstanding threads is generally in the 200-400 range, sometimes briefly going over 500. However, on macOS it is closer to 2400. This means a lot more ThreadReferences being tracked, which means more memory usage, so sometimes you see an OOME on macOS as a result. "

The threads collection mainly existed just so its size could be used to log the number of outstanding ThreadDeathEvents. I got rid of the threads collection and instead am just tracking the number of ThreadStartEvents and ThreadDeathEvents, and computing the difference to get the number of outstanding ThreadDeathEvents.

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

Commit messages:
 - update problem list
 - Fix GC related issues

Changes: https://git.openjdk.org/jdk/pull/13130/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13130&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8304436
  Stats: 16 lines in 2 files changed: 0 ins; 6 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/13130.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13130/head:pull/13130

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


More information about the serviceability-dev mailing list