Why JVM Heap Do Not Set Over 32g RAM
這篇介紹Why JVM Heap Do Not Set Over 32g RAM。
bytes example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Object header: 32位元: 8 bytes。 64位元: 開啟UseCompressedOops,使用12 bytes,反之會使用16 bytes。
Primitive: boolean 1 byte 1 short 2 char 2 int 4 float 4 long 8 double 8
Reference: 32位元: 4 bytes。 64位元: 開啟UseCompressedOops,使用4 bytes,反之會使用8 bytes。
|
32位元 versus 64位元
1 2 3 4 5 6 7 8 9 10 11
| 以同一個class來說 example: class C { int x; B y; }
32位元: 16 bytes 64位元: 32 bytes
會發現64位元相較32位元會需要使用2倍的RAM,實際平均是1.5倍。
|
conclusion
1 2 3
| 當Heap使用超過32g RAM時,JVM會停止使用UseCompressedOops參數, 改使用64位元的方式來運作,在64位元Heap使用40g會比不上開啟 UseCompressedOops使用的30g Heap。
|