src/share/vm/memory/metaspace.cpp

Print this page
rev 5310 : 8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space
Summary: Only put "Compressed class space" as OOM cause if actually using Compressed class space
Reviewed-by:

@@ -3100,11 +3100,11 @@
 }
 
 MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) {
   // DumpSharedSpaces doesn't use class metadata area (yet)
   // Also, don't use class_vsm() unless UseCompressedClassPointers is true.
-  if (mdtype == ClassType && using_class_space()) {
+  if (is_class_space_allocation(mdtype)) {
     return  class_vsm()->allocate(word_size);
   } else {
     return  vsm()->allocate(word_size);
   }
 }

@@ -3248,20 +3248,20 @@
           SIZE_FORMAT, word_size);
         if (loader_data->metaspace_or_null() != NULL) loader_data->dump(gclog_or_tty);
         MetaspaceAux::dump(gclog_or_tty);
       }
       // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
-      const char* space_string = (mdtype == ClassType) ? "Compressed class space" :
+      const char* space_string = (is_class_space_allocation(mdtype)) ? "Compressed class space" :
                                                          "Metadata space";
       report_java_out_of_memory(space_string);
 
       if (JvmtiExport::should_post_resource_exhausted()) {
         JvmtiExport::post_resource_exhausted(
             JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
             space_string);
       }
-      if (mdtype == ClassType) {
+      if (is_class_space_allocation(mdtype)) {
         THROW_OOP_0(Universe::out_of_memory_error_class_metaspace());
       } else {
         THROW_OOP_0(Universe::out_of_memory_error_metaspace());
       }
     }