5 ms·
Most useful info: If you run the 64 bit JRE and have memory problems, use the flags - Xcompressedrefs - XX:+UseCompressedOops for a decent 35-45% reduction
by dmichulke 10y ago
Most useful info:
If you run the 64 bit JRE and have memory problems, use the flags
- Xcompressedrefs
- XX:+UseCompressedOops
for a decent 35-45% reduction in memory use.
The rest is well-known stuff (use primitives, use arrays with fixed size, ...)
Still, the numbers are quite interesting (and the overhead quite scary)
- the8472 10y agoOn hotspot ergonomics automatically turn those options on as long as your max heap is < 32GiB. $ java -Xmx31G -XX:+PrintFlagsFinal 2>&1 | grep UseCompressed bool UseCompressedClassPointers := true {lp64_product} bool UseCompressedOops := true {lp64_product}
- nalllar 10y agoThey also can't be enabled with >32GiB heaps.
- the8472 10y agoThey can if you increase the object alignment, but that's generally not advisable and should only be done when measurements show a benefit.
- bogomipz 10y agoI think it depends on the JVM. You can use compressed refs on JRokit with > 32G heaps. Its a bit of "bit twiddling." This article explains it pretty well: https://blogs.oracle.com/jrockit/entry/understanding_compressed_refer https://blogs.oracle.com/jrockit/entry/understanding_compres...
- PDoyle 10y agoThis article is super old. Those options are now default, and the overhead is much smaller. (I think even in 2012, we already had 1-word headers.)