OutOfMemoryError: Compressed class space

14,470

Solution 1

Compressed Class space is part of the metaspace.

Looks like your resolution is to either increase max metaspace size, or you may potentially have a leaky classloader.

Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap. In this case, The garbage collector cannot make space available to accommodate a new object, and the heap cannot be expanded further. Also, this error may be thrown when there is insufficient native memory to support the loading of a Java class. In a rare instance, a java.lang.OutOfMemoryError may be thrown when an excessive amount of time is being spent doing garbage collection and little memory is being freed.

Solution 2

This exception is explained in Understand the OutOfMemoryError Exception:

Cause: On 64-bit platforms a pointer to class metadata can be represented by a 32-bit offset (with UseCompressedOops). This is controlled by the command line flag UseCompressedClassPointers (on by default). If the UseCompressedClassPointers is used, the amount of space available for class metadata is fixed at the amount CompressedClassSpaceSize. If the space needed for UseCompressedClassPointers exceeds CompressedClassSpaceSize, a java.lang.OutOfMemoryError with detail Compressed class space is thrown.

Action: Increase CompressedClassSpaceSize or you can turn off UseCompressedClassPointers. Note: There are bounds on the acceptable size of CompressedClassSpaceSize. For example -XX:CompressedClassSpaceSize=4g, exceeds acceptable bounds will result in a message such as CompressedClassSpaceSize of 4294967296 is invalid; must be between 1048576 and 3221225472.

Share:
14,470
user3167150
Author by

user3167150

Updated on June 11, 2022

Comments

  • user3167150
    user3167150 almost 2 years

    I got this error:

     "java.lang.OutOfMemoryError: Compressed class space"
    

    and until I'll figure out what's the trigger, I tried to disabling compressed class pointers with

    -XX:-UseCompressedClassPointers.

    but I still get this error. how is it possible?

    Thanks!