Skip to content
Permalink
Browse files
8261551: Remove special CDS handling in Metaspace::allocate
Reviewed-by: minqi, dholmes, stuefe
  • Loading branch information
iklam committed Mar 26, 2021
1 parent fe8ef32 commit 41657b15ac8322cc109d7f6105873ae388e48ff3
@@ -822,13 +822,6 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
}

if (result == NULL) {
if (DumpSharedSpaces) {
// CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
// We should abort to avoid generating a potentially bad archive.
vm_exit_during_cds_dumping(err_msg("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
MetaspaceObj::type_name(type), word_size * BytesPerWord),
err_msg("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize));
}
report_metadata_oome(loader_data, word_size, type, mdtype, THREAD);
assert(HAS_PENDING_EXCEPTION, "sanity");
return NULL;
@@ -612,7 +612,8 @@ void MetaspaceShared::prepare_for_dumping() {

// Preload classes from a list, populate the shared spaces and dump to a
// file.
void MetaspaceShared::preload_and_dump(TRAPS) {
void MetaspaceShared::preload_and_dump() {
EXCEPTION_MARK;
ResourceMark rm(THREAD);
preload_and_dump_impl(THREAD);
if (HAS_PENDING_EXCEPTION) {
@@ -77,7 +77,7 @@ class MetaspaceShared : AllStatic {
};

static void prepare_for_dumping() NOT_CDS_RETURN;
static void preload_and_dump(TRAPS) NOT_CDS_RETURN;
static void preload_and_dump() NOT_CDS_RETURN;

private:
static void preload_and_dump_impl(TRAPS) NOT_CDS_RETURN;
@@ -3413,7 +3413,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
#endif

if (DumpSharedSpaces) {
MetaspaceShared::preload_and_dump(CHECK_JNI_ERR);
MetaspaceShared::preload_and_dump();
ShouldNotReachHere();
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@@ -50,7 +50,7 @@ public static void main(String[] args) throws Exception {
processArgs.add("-XX:MaxMetaspaceSize=1m");
}

String msg = "Failed allocating metaspace object";
String msg = "OutOfMemoryError: Metaspace";
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(processArgs);
CDSTestUtils.executeAndLog(pb, "dump").shouldContain(msg).shouldHaveExitValue(1);
}

1 comment on commit 41657b1

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 41657b1 Mar 26, 2021

Please sign in to comment.