Bug in "loss due alignment" report?

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Oct 12 19:32:52 UTC 2015


Hi Jaromir,

On 10/10/2015 08:12 PM, Jaromir Hamala wrote:
> The alignment waste should be 7 and not 8 bytes and the element size should
> be 1. I realize it can be tricky to fix as the class parser does not have
> an access to the actual object instance, but the current report is rather
> misleading.

Yes, I agree.

And the reason you provided is exactly what is happening. Without
changing the class parser to accept the instance itself, it would be
hard to accommodate any variable-length instance.

Luckily, this is easy enough to fix. See:
 https://bugs.openjdk.java.net/browse/CODETOOLS-7901530

Notably, see a new sample:
 http://hg.openjdk.java.net/code-tools/jol/file/tip/jol-samples/src/main/java/org/openjdk/jol/samples/JOLSample_25_ArrayAlignment.java

Please test!

Thanks,
-Aleksey



More information about the jol-dev mailing list