OutOfMemoryError: Compressed class space in java




Contents of page >




In this tutorial we will solve Exception in thread threadName - java.lang.OutOfMemoryError: Compressed class space
1) Cause of OutOfMemoryError: Compressed class space  in java >
If you working on 64-bit platforms a pointer to class metadata can be represented by a 32-bit offset (by using vm option UseCompressedClassPointers - This vm option is enabled by default).


If vm option is kept enabled then amount of space available for class metadata is fixed (i.e. specified by vm option)


If amount of space available for class metadata is exceeds CompressedClassSpaceSize, then java.lang.OutOfMemoryError Compressed class space is thrown.
2) Example of using UseCompressedClassPointers vm option in java >
-XX: CompressedClassSpaceSize=2g
It will set size of 2 gigabyte.


Now, if space available for class metadata exceeds 2 gigabyte, then java.lang.OutOfMemoryError Compressed class space is thrown.


3) You must also know that there different type of class metadata -
  • klass metadata (only it is stored in CompressedClassSpaceSize) and
  • other metadata (it is not stored in CompressedClassSpaceSize, it is stored in Metaspace).


4) Summary -
So in this tutorial we learned that - If amount of space available for class metadata is exceeds CompressedClassSpaceSize, then java.lang.OutOfMemoryError Compressed class space is thrown.


Example of using UseCompressedClassPointers vm option in java >
-XX: CompressedClassSpaceSize=2g
Now, if space available for class metadata exceeds 2 gigabyte, then java.lang.OutOfMemoryError Compressed class space is thrown.


Different type of class metadata -
  • klass metadata (stored in CompressedClassSpaceSize) and
  • other metadata (not stored in CompressedClassSpaceSize, it is stored in Metaspace).


Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.


RELATED LINKS>


How to write java program to pass VM/JVM parameters through CMD



Most important and frequently used VM (JVM) PARAMETERS with examples in JVM Heap memory in java | Command Line arguments

How to monitor and analyze the garbage collection in 10 ways in java


Detecting and fixing memory leak in java

eEdit
Must read for you :