November 2017
Intermediate to advanced
398 pages
10h 14m
English
This is a rather rare form of the exception OutOfMemoryError. As the name suggests, this error occurs when garbage collector has reached its overhead limit. This means, it is running all the time, but is very slow in collecting objects. See the following example;
import java.util.Map;import java.util.Random;public class GCOverhead { public static void main(String args[]) throws Exception { Map map = System.getProperties(); Random r = new Random(); while (true) { map.put(r.nextInt(), "java 9"); } }}
Compile the previous program with javac and then use the following command:
java -Xmx100m -XX:+UseParallelGC GCOverhead
This will result in the java.lang.OutOfMemoryError: GC overhead limit ...