1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
296 if (HeapDumpOnOutOfMemoryError) {
297 tty->print_cr("java.lang.OutOfMemoryError: %s", message);
298 HeapDumper::dump_heap_from_oome();
299 }
300
301 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
302 VMError err(message);
303 err.report_java_out_of_memory();
304 }
305
306 if (CrashOnOutOfMemoryError) {
307 tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message);
308 fatal(err_msg("OutOfMemory encountered: %s", message));
309 }
310
311 if (ExitOnOutOfMemoryError) {
312 tty->print_cr("Terminating due to java.lang.OutOfMemoryError: %s", message);
313 exit(3);
314 }
315 }
316 }
317
318 static bool error_reported = false;
319
320 // call this when the VM is dying--it might loosen some asserts
321 void set_error_reported() {
322 error_reported = true;
323 }
324
325 bool is_error_reported() {
326 return error_reported;
327 }
328
329 #ifndef PRODUCT
330 #include <signal.h>
331
332 void test_error_handler() {
333 uintx test_num = ErrorHandlerTest;
334 if (test_num == 0) return;
335
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
296 if (HeapDumpOnOutOfMemoryError) {
297 tty->print_cr("java.lang.OutOfMemoryError: %s", message);
298 HeapDumper::dump_heap_from_oome();
299 }
300
301 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
302 VMError err(message);
303 err.report_java_out_of_memory();
304 }
305
306 if (CrashOnOutOfMemoryError) {
307 tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message);
308 fatal(err_msg("OutOfMemory encountered: %s", message));
309 }
310
311 if (ExitOnOutOfMemoryError) {
312 tty->print_cr("Terminating due to java.lang.OutOfMemoryError: %s", message);
313 exit(3);
314 }
315 }
316 }
317
318 void report_insufficient_metaspace(size_t required_size) {
319 warning("\nThe MaxMetaspaceSize of " SIZE_FORMAT " bytes is not large enough.\n"
320 "Either don't specify the -XX:MaxMetaspaceSize=<size>\n"
321 "or increase the size to at least " SIZE_FORMAT ".\n",
322 MaxMetaspaceSize, required_size);
323 exit(2);
324 }
325
326 static bool error_reported = false;
327
328 // call this when the VM is dying--it might loosen some asserts
329 void set_error_reported() {
330 error_reported = true;
331 }
332
333 bool is_error_reported() {
334 return error_reported;
335 }
336
337 #ifndef PRODUCT
338 #include <signal.h>
339
340 void test_error_handler() {
341 uintx test_num = ErrorHandlerTest;
342 if (test_num == 0) return;
343
|