Why MetaSpace Size is twice as big as Used MetaSpace?
I wrote a program to simulate MetaSpace OOM. But I found that MetaSpace Size is almost always twice as big as Used MetaSpace . Why? I run my program with flag -XX:MaxMetaspaceSize=50m , the program throw OOM when Used MetaSpace reached about 25M rather than 50M, Why? expoter I think the following two experiment will explain what does the gap between MetaSpace Size and Used MetaSpace mean: EXP-1 : load one class per ClassLoader, I got this: EXP-2 : load five classes per ClassLoader, I got this: As Java 8 document says: Space is requested from the OS and then divided into chunks. A class loader