--- old/src/share/vm/runtime/sweeper.cpp 2012-02-14 12:51:42.863072000 -0800 +++ new/src/share/vm/runtime/sweeper.cpp 2012-02-14 12:51:42.615979000 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -266,7 +266,13 @@ // The last invocation iterates until there are no more nmethods for (int i = 0; (i < todo || _invocations == 1) && _current != NULL; i++) { - + if (SafepointSynchronize::is_synchronizing()) { // Safepoint request + if (PrintMethodFlushing && Verbose) { + tty->print_cr("### Sweep at %d out of %d, aborting due to safepoint request", CodeCache::nof_nmethods(), _invocations); + } + _invocations++; // Restart this iteration later + break; // Bail out + } // Since we will give up the CodeCache_lock, always skip ahead // to the next nmethod. Other blobs can be deleted by other // threads but nmethods are only reclaimed by the sweeper.