1.1 --- a/src/share/vm/memory/metaspace.cpp Thu Oct 24 22:19:48 2013 -0700 1.2 +++ b/src/share/vm/memory/metaspace.cpp Fri Oct 25 11:05:32 2013 -0400 1.3 @@ -3312,6 +3312,11 @@ 1.4 return result; 1.5 } 1.6 1.7 +size_t Metaspace::class_chunk_size(size_t word_size) { 1.8 + assert(using_class_space(), "Has to use class space"); 1.9 + return class_vsm()->calc_chunk_size(word_size); 1.10 +} 1.11 + 1.12 void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetadataType mdtype, TRAPS) { 1.13 // If result is still null, we are out of memory. 1.14 if (Verbose && TraceMetadataChunkAllocation) { 1.15 @@ -3323,9 +3328,19 @@ 1.16 MetaspaceAux::dump(gclog_or_tty); 1.17 } 1.18 1.19 + bool out_of_compressed_class_space = false; 1.20 + if (is_class_space_allocation(mdtype)) { 1.21 + Metaspace* metaspace = loader_data->metaspace_non_null(); 1.22 + out_of_compressed_class_space = 1.23 + MetaspaceAux::committed_bytes(Metaspace::ClassType) + 1.24 + (metaspace->class_chunk_size(word_size) * BytesPerWord) > 1.25 + CompressedClassSpaceSize; 1.26 + } 1.27 + 1.28 // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support 1.29 - const char* space_string = is_class_space_allocation(mdtype) ? "Compressed class space" : 1.30 - "Metadata space"; 1.31 + const char* space_string = out_of_compressed_class_space ? 1.32 + "Compressed class space" : "Metaspace"; 1.33 + 1.34 report_java_out_of_memory(space_string); 1.35 1.36 if (JvmtiExport::should_post_resource_exhausted()) { 1.37 @@ -3338,7 +3353,7 @@ 1.38 vm_exit_during_initialization("OutOfMemoryError", space_string); 1.39 } 1.40 1.41 - if (is_class_space_allocation(mdtype)) { 1.42 + if (out_of_compressed_class_space) { 1.43 THROW_OOP(Universe::out_of_memory_error_class_metaspace()); 1.44 } else { 1.45 THROW_OOP(Universe::out_of_memory_error_metaspace());