diff -r 2c3cc4b01880 -r c16ac7a2eba4 src/hotspot/share/jfr/periodic/jfrPeriodic.cpp --- a/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp Wed Oct 30 16:14:56 2019 +0100 +++ b/src/hotspot/share/jfr/periodic/jfrPeriodic.cpp Wed Oct 30 19:43:52 2019 +0100 @@ -44,6 +44,7 @@ #include "jfr/periodic/jfrNetworkUtilization.hpp" #include "jfr/recorder/jfrRecorder.hpp" #include "jfr/support/jfrThreadId.hpp" +#include "jfr/utilities/jfrThreadIterator.hpp" #include "jfr/utilities/jfrTime.hpp" #include "jfrfiles/jfrPeriodic.hpp" #include "logging/log.hpp" @@ -56,7 +57,6 @@ #include "runtime/os.hpp" #include "runtime/os_perf.hpp" #include "runtime/thread.inline.hpp" -#include "runtime/threadSMR.hpp" #include "runtime/sweeper.hpp" #include "runtime/vmThread.hpp" #include "services/classLoadingService.hpp" @@ -410,13 +410,12 @@ GrowableArray allocated(initial_size); GrowableArray thread_ids(initial_size); JfrTicks time_stamp = JfrTicks::now(); - { - // Collect allocation statistics while holding threads lock - MutexLocker ml(Threads_lock); - for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) { - allocated.append(jt->cooked_allocated_bytes()); - thread_ids.append(JFR_THREAD_ID(jt)); - } + JfrJavaThreadIterator iter; + while (iter.has_next()) { + JavaThread* const jt = iter.next(); + assert(jt != NULL, "invariant"); + allocated.append(jt->cooked_allocated_bytes()); + thread_ids.append(JFR_THREAD_ID(jt)); } // Write allocation statistics to buffer.