--- old/src/share/vm/runtime/thread.cpp 2014-01-29 14:25:51.069428368 +0100 +++ new/src/share/vm/runtime/thread.cpp 2014-01-29 14:25:50.969429014 +0100 @@ -3476,6 +3476,16 @@ // any byte code. Now is a good time (the only time) to dump out the // internal state of the JVM for sharing. if (DumpSharedSpaces) { + // To be able to load and dump the internal state we need the young + // generation to be large enough to avoid triggering a GC. By default + // the minimal young size will be enough, but if specifying + // ObjectAlignmentInBytes > 8 we need to ensure that it is at least 4M. + if (ObjectAlignmentInBytes > 8 && NewSize < 4*M) { + vm_exit_during_initialization(err_msg("Incompatible NewSize (" SIZE_FORMAT + "K) for use with ObjectAlignmentInBytes=" SIZE_FORMAT " and -Xshare:dump," + " it needs to be at least " SIZE_FORMAT"K.", + NewSize/K, ObjectAlignmentInBytes, 4*M/K)); + } MetaspaceShared::preload_and_dump(CHECK_0); ShouldNotReachHere(); }