Errors of the Error class in Java

Errors in the Error class are the most serious problems at the JVM level. For example, exceptions of this kind arise if the memory available to the virtual machine runs out. It is not prohibited to handle such errors, but it is not recommended to do so.

OutOfMemoryError

An OutOfMemoryError is thrown when the Java virtual machine cannot create (allocate) an object due to insufficient memory and the garbage collector cannot reclaim enough memory.

The memory area occupied by a java process consists of several parts. The OutOfMemoryError type depends on which one ran out of space:

  • java.lang.OutOfMemoryError: Java heap space: There is not enough space on the heap, namely, in the area of ​​memory into which objects created in the application programmatically are placed. Usually the problem lies in a memory leak. The size is specified by the -Xms and -Xmx parameters.
  • java.lang.OutOfMemoryError: PermGen space: (prior to Java 8) This error occurs when there is not enough space in the Permanent area, the size of which is set by the -XX:PermSize and -XX:MaxPermSize parameters.
  • java.lang.OutOfMemoryError: GC overhead limit exceeded: This error can occur both when the first and second regions are overflowed. It is connected with the fact that there is little memory left and the garbage collector is constantly working, trying to free up some space. This error can be disabled using the -XX:-UseGCOverheadLimit parameter.
  • java.lang.OutOfMemoryError: unable to create new native thread: Thrown when it is not possible to create new threads.

Read also:


Comments

Popular posts from this blog

Methods for reading XML in Java

XML, well-formed XML and valid XML

ArrayList and LinkedList in Java, memory usage and speed