8025279: metaspace/flags/maxMetaspaceSize throws OOM: out of Compressed Klass space

Only put "Compressed class space" as OOM cause if actually using Compressed class space

Reviewed-by: jwilhelm, stefank, ehelin, coleenp
This commit is contained in:
Mikael Gerdin 2013-09-27 10:23:12 +02:00
parent bd9ffce267
commit 27565b7f5d
2 changed files with 7 additions and 4 deletions

View file

@ -3104,7 +3104,7 @@ size_t Metaspace::align_word_size_up(size_t word_size) {
MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) { MetaWord* Metaspace::allocate(size_t word_size, MetadataType mdtype) {
// DumpSharedSpaces doesn't use class metadata area (yet) // DumpSharedSpaces doesn't use class metadata area (yet)
// Also, don't use class_vsm() unless UseCompressedClassPointers is true. // 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); return class_vsm()->allocate(word_size);
} else { } else {
return vsm()->allocate(word_size); return vsm()->allocate(word_size);
@ -3252,7 +3252,7 @@ Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
MetaspaceAux::dump(gclog_or_tty); MetaspaceAux::dump(gclog_or_tty);
} }
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support // -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"; "Metadata space";
report_java_out_of_memory(space_string); report_java_out_of_memory(space_string);
@ -3261,7 +3261,7 @@ Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR, JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
space_string); space_string);
} }
if (mdtype == ClassType) { if (is_class_space_allocation(mdtype)) {
THROW_OOP_0(Universe::out_of_memory_error_class_metaspace()); THROW_OOP_0(Universe::out_of_memory_error_class_metaspace());
} else { } else {
THROW_OOP_0(Universe::out_of_memory_error_metaspace()); THROW_OOP_0(Universe::out_of_memory_error_metaspace());

View file

@ -235,6 +235,9 @@ class Metaspace : public CHeapObj<mtClass> {
return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers && !DumpSharedSpaces); return NOT_LP64(false) LP64_ONLY(UseCompressedClassPointers && !DumpSharedSpaces);
} }
static bool is_class_space_allocation(MetadataType mdType) {
return mdType == ClassType && using_class_space();
}
}; };
class MetaspaceAux : AllStatic { class MetaspaceAux : AllStatic {