# HG changeset patch # User kevinw # Date 1508947799 -3600 # Node ID 3413fb2061fb1a4bb866e4af5d2b3f0270aadcfd # Parent f631660ef0a31022922261463ab3376a3ee50311 8138745, PR3465, RH1484399: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot Reviewed-by: dholmes Contributed-by: cheleswer.sahu@oracle.com diff -r f631660ef0a3 -r 3413fb2061fb src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Fri Aug 11 23:51:07 2017 -0400 +++ b/src/share/vm/runtime/globals.hpp Wed Oct 25 17:09:59 2017 +0100 @@ -1247,6 +1247,13 @@ "in perm. This purely intended to allow debugging issues" \ "in production.") \ \ + product(bool, ExitOnOutOfMemoryError, false, \ + "JVM exits on the first occurrence of an out-of-memory error") \ + \ + product(bool, CrashOnOutOfMemoryError, false, \ + "JVM aborts, producing an error log and core/mini dump, on the " \ + "first occurrence of an out-of-memory error") \ + \ /* tracing */ \ \ notproduct(bool, TraceRuntimeCalls, false, \ diff -r f631660ef0a3 -r 3413fb2061fb src/share/vm/utilities/debug.cpp --- a/src/share/vm/utilities/debug.cpp Fri Aug 11 23:51:07 2017 -0400 +++ b/src/share/vm/utilities/debug.cpp Wed Oct 25 17:09:59 2017 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -317,6 +317,16 @@ VMError err(message); err.report_java_out_of_memory(); } + + if (CrashOnOutOfMemoryError) { + tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message); + fatal(err_msg("OutOfMemory encountered: %s", message)); + } + + if (ExitOnOutOfMemoryError) { + tty->print_cr("Terminating due to java.lang.OutOfMemoryError: %s", message); + exit(3); + } } }