1253 // CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
1254 // We should abort to avoid generating a potentially bad archive.
1255 tty->print_cr("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
1256 MetaspaceObj::type_name(type), word_size * BytesPerWord);
1257 tty->print_cr("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize);
1258 vm_exit(1);
1259 }
1260 report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL);
1261 }
1262
1263 // Zero initialize.
1264 Copy::fill_to_words((HeapWord*)result, word_size, 0);
1265
1266 return result;
1267 }
1268
1269 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) {
1270 tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
1271
1272 // If result is still null, we are out of memory.
1273 Log(gc, metaspace, freelist) log;
1274 if (log.is_info()) {
1275 log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT,
1276 is_class_space_allocation(mdtype) ? "class" : "data", word_size);
1277 ResourceMark rm;
1278 if (log.is_debug()) {
1279 if (loader_data->metaspace_or_null() != NULL) {
1280 LogStream ls(log.debug());
1281 loader_data->print_value_on(&ls);
1282 }
1283 }
1284 LogStream ls(log.info());
1285 // In case of an OOM, log out a short but still useful report.
1286 MetaspaceUtils::print_basic_report(&ls, 0);
1287 }
1288
1289 bool out_of_compressed_class_space = false;
1290 if (is_class_space_allocation(mdtype)) {
1291 ClassLoaderMetaspace* metaspace = loader_data->metaspace_non_null();
1292 out_of_compressed_class_space =
1293 MetaspaceUtils::committed_bytes(Metaspace::ClassType) +
|
1253 // CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
1254 // We should abort to avoid generating a potentially bad archive.
1255 tty->print_cr("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
1256 MetaspaceObj::type_name(type), word_size * BytesPerWord);
1257 tty->print_cr("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize);
1258 vm_exit(1);
1259 }
1260 report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL);
1261 }
1262
1263 // Zero initialize.
1264 Copy::fill_to_words((HeapWord*)result, word_size, 0);
1265
1266 return result;
1267 }
1268
1269 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) {
1270 tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
1271
1272 // If result is still null, we are out of memory.
1273 Log(gc, metaspace, freelist, oom) log;
1274 if (log.is_info()) {
1275 log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT,
1276 is_class_space_allocation(mdtype) ? "class" : "data", word_size);
1277 ResourceMark rm;
1278 if (log.is_debug()) {
1279 if (loader_data->metaspace_or_null() != NULL) {
1280 LogStream ls(log.debug());
1281 loader_data->print_value_on(&ls);
1282 }
1283 }
1284 LogStream ls(log.info());
1285 // In case of an OOM, log out a short but still useful report.
1286 MetaspaceUtils::print_basic_report(&ls, 0);
1287 }
1288
1289 bool out_of_compressed_class_space = false;
1290 if (is_class_space_allocation(mdtype)) {
1291 ClassLoaderMetaspace* metaspace = loader_data->metaspace_non_null();
1292 out_of_compressed_class_space =
1293 MetaspaceUtils::committed_bytes(Metaspace::ClassType) +
|