java OutOfMemoryError:压缩的类空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35162542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
OutOfMemoryError: Compressed class space
提问by user3167150
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.
-XX:-UseCompressedClassPointers.
but I still get this error. how is it possible?
但我仍然收到此错误。这怎么可能?
Thanks!
谢谢!
采纳答案by Ihor Sh
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.
通常,当 Java 堆中没有足够的空间分配对象时会抛出此错误。在这种情况下,垃圾收集器无法腾出空间来容纳新对象,堆也无法进一步扩展。此外,当本机内存不足以支持 Java 类的加载时,可能会抛出此错误。在极少数情况下,当花费过多时间进行垃圾收集并且释放的内存很少时,可能会抛出 java.lang.OutOfMemoryError 。
回答by alban
This exception is explained in Understand the OutOfMemoryError Exception:
理解 OutOfMemoryError 异常中解释了此异常:
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 flagUseCompressedClassPointers
(on by default). If theUseCompressedClassPointers
is used, the amount of space available for class metadata is fixed at the amountCompressedClassSpaceSize
. If the space needed forUseCompressedClassPointers
exceedsCompressedClassSpaceSize
, ajava.lang.OutOfMemoryError
with detail Compressed class spaceis thrown.Action: Increase
CompressedClassSpaceSize
or you can turn offUseCompressedClassPointers
. Note: There are bounds on the acceptable size ofCompressedClassSpaceSize
. 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.
原因:在 64 位平台上,指向类元数据的指针可以用 32 位偏移量(带有
UseCompressedOops
)表示。这由命令行标志控制UseCompressedClassPointers
(默认情况下打开)。如果UseCompressedClassPointers
使用 ,则可用于类元数据的空间量固定为数量CompressedClassSpaceSize
。如果需要的空间UseCompressedClassPointers
超过CompressedClassSpaceSize
,则会抛出一个java.lang.OutOfMemoryError
带有详细信息的压缩类空间。行动:增加
CompressedClassSpaceSize
或您可以关闭UseCompressedClassPointers
。注意: 的可接受大小是有界限的CompressedClassSpaceSize
。例如-XX:CompressedClassSpaceSize=4g
,超出可接受的界限会导致CompressedClassSpaceSize of 4294967296等消息无效;必须介于 1048576 和 3221225472 之间。