2016-02-02 32 views
3

我得到這個錯誤:的OutOfMemoryError:壓縮類空間

"java.lang.OutOfMemoryError: Compressed class space" 

,直到我會想出什麼觸發,我試圖 禁用壓縮類指針與

-XX:-UseCompressedClassPointers.

但我仍然得到這個錯誤。這怎麼可能?

謝謝!

回答

2

壓縮類空間是元空間的一部分。

看起來像您的決議是要麼增加最大的元空間大小,要麼你可能有一個泄漏的類加載器。

通常,如果沒有足夠的空間在Java堆中分配對象,則會引發此錯誤。在這種情況下,垃圾收集器不能使空間可用來容納新對象,並且堆不能進一步擴展。另外,如果沒有足夠的本機內存來支持加載Java類,則可能會引發此錯誤。在極少數情況下,如果花費過多的時間進行垃圾收集並且釋放少量內存,則可能會拋出java.lang.OutOfMemoryError。

+1

一些細節將有助於例如顯示增加最大元空間大小的選項。 –

2

這種異常在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 to 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.