Please review this PR that makes `TestDockerMemoryMetrics.java` more robust.
The failcount case of `TestDockerMemoryMetrics.java` is still failing on some
systems.
With this change I trying to address serveral issues:
* the test did not set swap-space, and so left it for the OS/container runtime
to choose.
* request swap space with `--memory-swap`` with enough headroom for JVM in
container so that failcount gets more chances to be updated. It may be that
some OSes are more eager the others to update counters in cgroup-fs.
* the `new byte[1 MiB]` allocations alone reserves heap space for the
application space but may leave the memory uncommitted. Eventually the 512 MiB
Java heap fills and throws OutOfMemoryError, while actual cgroup-charged memory
remains below memory ceiling 128 MiB.
* touch chunks of memory we allocate.
* remoted catch'ing `OutOfMemoryError` to avoid secondary `OutOfMemoryError`.
* The test inherits JVM flags set externally and so `-Xmx` is often passed to
the JVM running in a container.
* Make `-Xmx` flag set from within the test to *win* over the one set
externally (e.g. by our make scripts for task definition).
Tested `TestDockerMemoryMetrics.java` on
* Ubuntu 24.04 x {Podman, Docker}
* OL9,10 + Podman
---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK
Interim AI Policy](https://openjdk.org/legal/ai).
-------------
Commit messages:
- prefer longer version of flags. Correct the ASCII graph
- more comment tweaks
- few more enhancements and checks
- update the copyright year to 2026
- small correction. comments
- 8390065: make TestDockerMemoryMetrics.java more robust
Changes: https://git.openjdk.org/jdk/pull/32300/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=32300&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8390065
Stats: 75 lines in 2 files changed: 27 ins; 1 del; 47 mod
Patch: https://git.openjdk.org/jdk/pull/32300.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/32300/head:pull/32300
PR: https://git.openjdk.org/jdk/pull/32300