3354
3355 MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
3356
3357 // Try to allocate metadata.
3358 MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
3359
3360 if (result == NULL) {
3361 tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype);
3362
3363 // Allocation failed.
3364 if (is_init_completed()) {
3365 // Only start a GC if the bootstrapping has completed.
3366
3367 // Try to clean out some memory and retry.
3368 result = Universe::heap()->collector_policy()->satisfy_failed_metadata_allocation(
3369 loader_data, word_size, mdtype);
3370 }
3371 }
3372
3373 if (result == NULL) {
3374 report_metadata_oome(loader_data, word_size, mdtype, CHECK_NULL);
3375 }
3376
3377 // Zero initialize.
3378 Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0);
3379
3380 return result;
3381 }
3382
3383 size_t Metaspace::class_chunk_size(size_t word_size) {
3384 assert(using_class_space(), "Has to use class space");
3385 return class_vsm()->calc_chunk_size(word_size);
3386 }
3387
3388 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetadataType mdtype, TRAPS) {
3389 // If result is still null, we are out of memory.
3390 if (Verbose && TraceMetadataChunkAllocation) {
3391 gclog_or_tty->print_cr("Metaspace allocation failed for size "
3392 SIZE_FORMAT, word_size);
3393 if (loader_data->metaspace_or_null() != NULL) {
3394 loader_data->dump(gclog_or_tty);
3395 }
3396 MetaspaceAux::dump(gclog_or_tty);
3397 }
3398
3399 bool out_of_compressed_class_space = false;
3400 if (is_class_space_allocation(mdtype)) {
3401 Metaspace* metaspace = loader_data->metaspace_non_null();
3402 out_of_compressed_class_space =
3403 MetaspaceAux::committed_bytes(Metaspace::ClassType) +
3404 (metaspace->class_chunk_size(word_size) * BytesPerWord) >
3405 CompressedClassSpaceSize;
3406 }
3407
3408 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
|
3354
3355 MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
3356
3357 // Try to allocate metadata.
3358 MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
3359
3360 if (result == NULL) {
3361 tracer()->report_metaspace_allocation_failure(loader_data, word_size, type, mdtype);
3362
3363 // Allocation failed.
3364 if (is_init_completed()) {
3365 // Only start a GC if the bootstrapping has completed.
3366
3367 // Try to clean out some memory and retry.
3368 result = Universe::heap()->collector_policy()->satisfy_failed_metadata_allocation(
3369 loader_data, word_size, mdtype);
3370 }
3371 }
3372
3373 if (result == NULL) {
3374 report_metadata_oome(loader_data, word_size, type, mdtype, CHECK_NULL);
3375 }
3376
3377 // Zero initialize.
3378 Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0);
3379
3380 return result;
3381 }
3382
3383 size_t Metaspace::class_chunk_size(size_t word_size) {
3384 assert(using_class_space(), "Has to use class space");
3385 return class_vsm()->calc_chunk_size(word_size);
3386 }
3387
3388 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS) {
3389 tracer()->report_metadata_oom(loader_data, word_size, type, mdtype);
3390
3391 // If result is still null, we are out of memory.
3392 if (Verbose && TraceMetadataChunkAllocation) {
3393 gclog_or_tty->print_cr("Metaspace allocation failed for size "
3394 SIZE_FORMAT, word_size);
3395 if (loader_data->metaspace_or_null() != NULL) {
3396 loader_data->dump(gclog_or_tty);
3397 }
3398 MetaspaceAux::dump(gclog_or_tty);
3399 }
3400
3401 bool out_of_compressed_class_space = false;
3402 if (is_class_space_allocation(mdtype)) {
3403 Metaspace* metaspace = loader_data->metaspace_non_null();
3404 out_of_compressed_class_space =
3405 MetaspaceAux::committed_bytes(Metaspace::ClassType) +
3406 (metaspace->class_chunk_size(word_size) * BytesPerWord) >
3407 CompressedClassSpaceSize;
3408 }
3409
3410 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
|