Skip to content

Instantly share code, notes, and snippets.

View tstuefe's full-sized avatar
🎯
Focusing

Thomas Stuefe tstuefe

🎯
Focusing
View GitHub Profile
@tstuefe
tstuefe / ccptr.md
Last active April 19, 2023 11:31
class space compact oh

Today's compressed class pointers encode a 64-bit pointer into 32 bits. Introduced with JDK 8, compressed class pointers first depended on compressed object pointers; with JDK 15, this dependency was removed (JDK-8241825). Enabling compressed class pointers is highly desirable. Today, only two reasons remain that require an application to disable compressed class pointers:

  • It uses JVMCI, which on some platforms inhibits the use of compressed class pointers.
  • It loads more than roughly three million classes. This limit is imposed by the way class space is implemented today. Note that the latter limit is theoretical - an application that hits this limit would use approximately six to ~30 GB for metaspace alone; we have yet to find an application that does.

Compact object headers will limit the bits available to identify a class to 32 bits or less. The feature, therefore, requires compressed class pointers to be enabled unconditionally. The cases mentioned abo

```
0x0000000000000001 0000000000000000000000000000000000000000000000000000000000000001 (size=64, length=1, rotation=0)
0x0000000000000002 0000000000000000000000000000000000000000000000000000000000000010 (size=64, length=1, rotation=1)
0x0000000000000003 0000000000000000000000000000000000000000000000000000000000000011 (size=64, length=2, rotation=0)
0x0000000000000004 0000000000000000000000000000000000000000000000000000000000000100 (size=64, length=1, rotation=2)
0x0000000000000006 0000000000000000000000000000000000000000000000000000000000000110 (size=64, length=2, rotation=1)
0x0000000000000007 0000000000000000000000000000000000000000000000000000000000000111 (size=64, length=3, rotation=0)
0x0000000000000008 0000000000000000000000000000000000000000000000000000000000001000 (size=64, length=1, rotation=3)
0x000000000000000c 0000000000000000000000000000000000000000000000000000000000001100 (size=64, length=2, rotation=2)