< prev index next >

src/hotspot/share/memory/metaspace.cpp

Print this page
rev 50985 : 8206977: Minor improvements of runtime code.
Reviewed-by: coleenp, lfoltan


1243     // Allocation failed.
1244     if (is_init_completed() && !(DumpSharedSpaces && THREAD->is_VM_thread())) {
1245       // Only start a GC if the bootstrapping has completed.
1246       // Also, we cannot GC if we are at the end of the CDS dumping stage which runs inside
1247       // the VM thread.
1248 
1249       // Try to clean out some memory and retry.
1250       result = Universe::heap()->satisfy_failed_metadata_allocation(loader_data, word_size, mdtype);
1251     }
1252   }
1253 
1254   if (result == NULL) {
1255     if (DumpSharedSpaces) {
1256       // CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
1257       // We should abort to avoid generating a potentially bad archive.
1258       tty->print_cr("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
1259           MetaspaceObj::type_name(type), word_size * BytesPerWord);
1260       tty->print_cr("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize);
1261       vm_exit(1);
1262     }
1263     report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL);


1264   }
1265 
1266   // Zero initialize.
1267   Copy::fill_to_words((HeapWord*)result, word_size, 0);
1268 
1269   return result;
1270 }
1271 
1272 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) {
1273   tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
1274 
1275   // If result is still null, we are out of memory.
1276   Log(gc, metaspace, freelist, oom) log;
1277   if (log.is_info()) {
1278     log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT,
1279              is_class_space_allocation(mdtype) ? "class" : "data", word_size);
1280     ResourceMark rm;
1281     if (log.is_debug()) {
1282       if (loader_data->metaspace_or_null() != NULL) {
1283         LogStream ls(log.debug());




1243     // Allocation failed.
1244     if (is_init_completed() && !(DumpSharedSpaces && THREAD->is_VM_thread())) {
1245       // Only start a GC if the bootstrapping has completed.
1246       // Also, we cannot GC if we are at the end of the CDS dumping stage which runs inside
1247       // the VM thread.
1248 
1249       // Try to clean out some memory and retry.
1250       result = Universe::heap()->satisfy_failed_metadata_allocation(loader_data, word_size, mdtype);
1251     }
1252   }
1253 
1254   if (result == NULL) {
1255     if (DumpSharedSpaces) {
1256       // CDS dumping keeps loading classes, so if we hit an OOM we probably will keep hitting OOM.
1257       // We should abort to avoid generating a potentially bad archive.
1258       tty->print_cr("Failed allocating metaspace object type %s of size " SIZE_FORMAT ". CDS dump aborted.",
1259           MetaspaceObj::type_name(type), word_size * BytesPerWord);
1260       tty->print_cr("Please increase MaxMetaspaceSize (currently " SIZE_FORMAT " bytes).", MaxMetaspaceSize);
1261       vm_exit(1);
1262     }
1263     report_metadata_oome(loader_data, word_size, type, mdtype, THREAD);
1264     assert(HAS_PENDING_EXCEPTION, "sanity");
1265     return NULL;
1266   }
1267 
1268   // Zero initialize.
1269   Copy::fill_to_words((HeapWord*)result, word_size, 0);
1270 
1271   return result;
1272 }
1273 
1274 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) {
1275   tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
1276 
1277   // If result is still null, we are out of memory.
1278   Log(gc, metaspace, freelist, oom) log;
1279   if (log.is_info()) {
1280     log.info("Metaspace (%s) allocation failed for size " SIZE_FORMAT,
1281              is_class_space_allocation(mdtype) ? "class" : "data", word_size);
1282     ResourceMark rm;
1283     if (log.is_debug()) {
1284       if (loader_data->metaspace_or_null() != NULL) {
1285         LogStream ls(log.debug());


< prev index next >