问题
Following my question on whether the CLR could use compressed pointers, the answer was that it's pretty pointless. Still, some JVMs are implementing it, so what are the concrete benefits of this optimization, since gaining 4 bytes doesn't seem worth it?
回答1:
There is huge value in compressed references. First, on x86, 64 bit modes unlock 8 new registers to be used, which is a huge performance win. Second, using 4 byte instead of 8 byte headers / object pointers significantly improves cache efficiency. We see real-world benefits in IBM Java on the order of ~5-10% relative to a "full" 64 bit JVM (your mileage will vary). This makes moving to "small 64 bit" heaps an easy and painless thing, breaking past the ~2gb memory limit in 32 bit JVMs. (the real 32 bit limit it could be anywhere from 1700mb to ~3.7gb depending on the OS).
回答2:
You can gain 4 bytes from every object reference. If object has more references, it's common in java object, you can save more memory. Small object size could cause 2 results, first, the GC pause time is reduced. 2nd, cache hit rate is increased. So java application could gain performance improvement. For benchmark test, enable CompressedOops could improve performance by 5%~10% .
回答3:
If your main goal is to avoid garbage collections altogether, or at least have less frequent GC runs, it is worth it, since it can lead to substantial lower memory footprints.
来源:https://stackoverflow.com/questions/6905594/whats-the-purpose-of-compressed-object-pointers