(See also https://bugs.openjdk.org/browse/JDK-8372389, which proposed to omit
these entirely)
Heap filler arrays are stored internally as int typearrays, and currently
dumped as `int[]` in heap dumps. This is confusing for users, as these filler
arrays are not distinguishable from real user int arrays.
To distinguish them, dump them as `FillerElement[]` instead with null elements.
This also removes the security issue of dumping random heap data in filler
arrays.
Implementation note: I have kept the length of the emitted object array the
same as the underlying type array. That means the array lengths in the dump
will be 'correct', but tools like MAT which estimate the array footprint based
on heap size/compressed oops enablement will estimate double the true size for
JVMs with uncompressed oops (`int[100]`, 400 bytes of data, becomes
`FillerElement[100]`, 800 estimated bytes of data). We *could* instead adjust
the length to give a better size estimate, if desired.
Using Eclipse MAT, before:
before.hprof - 2.6GB
Class Name | Objects | Shallow Heap
=====================================
int[] 5,542 1.40GB
After:
after.hprof - 3.7GB
Class Name | Objects | Shallow Heap
============================================================
jdk.internal.vm.FillerElement[] 69 1.10GB
int[] 5,482 1.50MB
Performance seems to be similar, but dumps with lots of filler elements are
bigger because elements take 8 bytes instead of 4. Very compressible, though.
---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK
Interim AI Policy](https://openjdk.org/legal/ai).
-------------
Commit messages:
- 8391761: Emit FillerElement[] instead of int[] in heap dump
Changes: https://git.openjdk.org/jdk/pull/32687/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=32687&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8391761
Stats: 44 lines in 1 file changed: 37 ins; 2 del; 5 mod
Patch: https://git.openjdk.org/jdk/pull/32687.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/32687/head:pull/32687
PR: https://git.openjdk.org/jdk/pull/32687