src/share/vm/gc_implementation/shared/vmGCOperations.cpp
Print this page
@@ -102,10 +102,18 @@
bool VM_GC_Operation::doit_prologue() {
assert(Thread::current()->is_Java_thread(), "just checking");
assert(((_gc_cause != GCCause::_no_gc) &&
(_gc_cause != GCCause::_no_cause_specified)), "Illegal GCCause");
+ // If a GC is initiated during startup and the the GC locker is locked,
+ // the VM initialization will fail because we are not yet ready to handle
+ // a GC.
+ if (GC_locker::fail_on_gc()) {
+ vm_exit_during_initialization(
+ err_msg("Too small young generation (" SIZE_FORMAT "K) to initialize VM.", NewSize / K));
+ }
+
acquire_pending_list_lock();
// If the GC count has changed someone beat us to the collection
// Get the Heap_lock after the pending_list_lock.
Heap_lock->lock();