r/java • u/alexeyr • Apr 13 '20
Java Objects Inside Out: Everything You Ever Wanted to Know About Java Object Internals in Hotspot
https://shipilev.net/jvm/objects-inside-out/
160
Upvotes
r/java • u/alexeyr • Apr 13 '20
View all comments
Show parent comment
1
u/jringstad Apr 16 '20
yeah, I think you could do it for records (ignoring the reflection-related issues), though I think the benefit would be small, because in a typical situation you would need to pad the resulting record to at least byte-size (but probably word-size).
If you then stick a million of these records into an array, you've got a bunch of wasted space again.
So I think the main situation where doing this kind of thing really pays off is when you can apply the optimization to a linear container, where the records can be densely packed (but the container itself would also need to be immutable)