OutOfMemoryError: Compressed class space

OutOfMemoryError: Compressed class space

我收到这个错误:

 "java.lang.OutOfMemoryError: Compressed class space"

直到我弄清楚触发因素是什么,我才尝试 使用

禁用压缩的 class 指针

-XX:-UseCompressedClassPointers.

但我仍然收到此错误。怎么可能?

谢谢!

压缩 Class space 是元数据的一部分space。

看来您的解决方案是增加最大元space 大小,或者您的 classloader 可能有漏洞。

通常,当 space 不足以在 Java 堆中分配对象时,会抛出此错误。在这种情况下,垃圾收集器无法使 space 可用于容纳新对象,并且无法进一步扩展堆。此外,当本机内存不足以支持加载 Java class 时,可能会抛出此错误。在极少数情况下,当花费过多时间进行垃圾收集并且释放的内存很少时,可能会抛出 java.lang.OutOfMemoryError。

此异常在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.