Java – OutOfMemoryError

OutOfMemoryError: Thrown when the JVM cannot allocate an object due to insufficient memory.
Example:

try {
int[] arr = new int[Integer.MAX_VALUE];
} catch (OutOfMemoryError e) {
System.out.println("Caught OutOfMemoryError: " + e.getMessage());
}

No images available.