Java Heap Space is a dedicated memory area within the Java Virtual Machine (JVM) that stores object instances. When a new object is created, it is allocated memory from the Java Heap Space. If the Java Heap Space runs out of memory, a java.lang.OutOfMemoryError exception is thrown.
There are a number of ways to avoid java heap space errors. One common approach is to increase the size of the Java Heap Space. This can be done by setting the -Xmx parameter when starting the JVM. For example, the following command will increase the maximum heap size to 1GB: