3310 Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0); |
3310 Copy::fill_to_aligned_words((HeapWord*)result, word_size, 0); |
3311 |
3311 |
3312 return result; |
3312 return result; |
3313 } |
3313 } |
3314 |
3314 |
|
3315 size_t Metaspace::class_chunk_size(size_t word_size) { |
|
3316 assert(using_class_space(), "Has to use class space"); |
|
3317 return class_vsm()->calc_chunk_size(word_size); |
|
3318 } |
|
3319 |
3315 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetadataType mdtype, TRAPS) { |
3320 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetadataType mdtype, TRAPS) { |
3316 // If result is still null, we are out of memory. |
3321 // If result is still null, we are out of memory. |
3317 if (Verbose && TraceMetadataChunkAllocation) { |
3322 if (Verbose && TraceMetadataChunkAllocation) { |
3318 gclog_or_tty->print_cr("Metaspace allocation failed for size " |
3323 gclog_or_tty->print_cr("Metaspace allocation failed for size " |
3319 SIZE_FORMAT, word_size); |
3324 SIZE_FORMAT, word_size); |
3321 loader_data->dump(gclog_or_tty); |
3326 loader_data->dump(gclog_or_tty); |
3322 } |
3327 } |
3323 MetaspaceAux::dump(gclog_or_tty); |
3328 MetaspaceAux::dump(gclog_or_tty); |
3324 } |
3329 } |
3325 |
3330 |
|
3331 bool out_of_compressed_class_space = false; |
|
3332 if (is_class_space_allocation(mdtype)) { |
|
3333 Metaspace* metaspace = loader_data->metaspace_non_null(); |
|
3334 out_of_compressed_class_space = |
|
3335 MetaspaceAux::committed_bytes(Metaspace::ClassType) + |
|
3336 (metaspace->class_chunk_size(word_size) * BytesPerWord) > |
|
3337 CompressedClassSpaceSize; |
|
3338 } |
|
3339 |
3326 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support |
3340 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support |
3327 const char* space_string = is_class_space_allocation(mdtype) ? "Compressed class space" : |
3341 const char* space_string = out_of_compressed_class_space ? |
3328 "Metadata space"; |
3342 "Compressed class space" : "Metaspace"; |
|
3343 |
3329 report_java_out_of_memory(space_string); |
3344 report_java_out_of_memory(space_string); |
3330 |
3345 |
3331 if (JvmtiExport::should_post_resource_exhausted()) { |
3346 if (JvmtiExport::should_post_resource_exhausted()) { |
3332 JvmtiExport::post_resource_exhausted( |
3347 JvmtiExport::post_resource_exhausted( |
3333 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, |
3348 JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, |
3336 |
3351 |
3337 if (!is_init_completed()) { |
3352 if (!is_init_completed()) { |
3338 vm_exit_during_initialization("OutOfMemoryError", space_string); |
3353 vm_exit_during_initialization("OutOfMemoryError", space_string); |
3339 } |
3354 } |
3340 |
3355 |
3341 if (is_class_space_allocation(mdtype)) { |
3356 if (out_of_compressed_class_space) { |
3342 THROW_OOP(Universe::out_of_memory_error_class_metaspace()); |
3357 THROW_OOP(Universe::out_of_memory_error_class_metaspace()); |
3343 } else { |
3358 } else { |
3344 THROW_OOP(Universe::out_of_memory_error_metaspace()); |
3359 THROW_OOP(Universe::out_of_memory_error_metaspace()); |
3345 } |
3360 } |
3346 } |
3361 } |