Skip to Content
Java 9 High Performance
book

Java 9 High Performance

by Mayur Ramgir, Nick Samoylov
November 2017
Intermediate to advanced
398 pages
10h 14m
English
Packt Publishing
Content preview from Java 9 High Performance

java.lang.OutOfMemoryError: GC Overhead limit exceeded

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Distributed Computing in Java 9

Distributed Computing in Java 9

Raja Malleswara Rao Malleswara Rao Pattamsetti
Mastering Java 11 - Second Edition

Mastering Java 11 - Second Edition

Dr. Edward Lavieri Jr., Mandar Jog
Java EE 8 High Performance

Java EE 8 High Performance

Romain Manni-Bucau
Clojure: High Performance JVM Programming

Clojure: High Performance JVM Programming

Eduardo Díaz, Shantanu Kumar, Akhil Wali

Publisher Resources

ISBN: 9781787120785Supplemental Content