java how to track and tune Compression Class Space

857 Views Asked by At

We're using JDK 8 and some of our processes are giving OOM with "compressed class space". We're logging GC and our jvm statistics.log file currently gives the following type of log entries

2017-06-30 03:57:07,944 INFO - HEAP - [USAGE: 1678.7, FREE: 986.7, TOTAL: 2665.5, MAX: 2665.5]; PERM - [USAGE: N/A, FREE: N/A, MAX: N/A]; CLASSES - [Loaded: 1832624, Unloaded: 637, Left: 1831987]; THREADS - [Count: 92]

We're wondering if adding the flags "-XX:+TraceClassUnloading -XX:+TraceClassLoading" would let us know what value we should set for the "Compressed Class space" ( -XX: CompressedClassSpaceSize) ? If yes, how do we determine the size from the Trace logs ?

1

There are 1 best solutions below

1
On

You can use -XX:-UseCompressedClassPointers to disable the compressed class space which should allow the JVM to load as many classes as fit into memory instead of the limited compressed class virtual memory region. The drawback are larger class pointers in object headers.

But as @Holger mentioned in the comments you should make sure that your application isn't leaking classes over time, otherwise memory consumption will keep growing.