< prev index next >

src/hotspot/share/runtime/memprofiler.cpp

Print this page
rev 47794 : Port 09.17.Thread_SMR_logging_update from JDK9 to JDK10
rev 47796 : eosterlund, stefank CR - refactor code into threadSMR.cpp and threadSMR.hpp
rev 47799 : stefank, coleenp CR - refactor most JavaThreadIterator usage to use JavaThreadIteratorWithHandle.

@@ -34,10 +34,11 @@
 #include "runtime/memprofiler.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/os.hpp"
 #include "runtime/task.hpp"
 #include "runtime/thread.inline.hpp"
+#include "runtime/threadSMR.hpp"
 #include "runtime/vmThread.hpp"
 
 #ifndef PRODUCT
 
 // --------------------------------------------------------

@@ -107,24 +108,25 @@
 
 void MemProfiler::do_trace() {
   // Calculate thread local sizes
   size_t handles_memory_usage    = VMThread::vm_thread()->handle_area()->size_in_bytes();
   size_t resource_memory_usage   = VMThread::vm_thread()->resource_area()->size_in_bytes();
-  JavaThread *cur = Threads::first();
-  while (cur != NULL) {
+  {
+    JavaThreadIteratorWithHandle jtiwh;
+    for (; JavaThread *cur = jtiwh.next(); ) {
     handles_memory_usage  += cur->handle_area()->size_in_bytes();
     resource_memory_usage += cur->resource_area()->size_in_bytes();
-    cur = cur->next();
   }
 
   // Print trace line in log
   fprintf(_log_fp, "%6.1f,%5d,%5d," UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) ",",
           os::elapsedTime(),
-          Threads::number_of_threads(),
+            jtiwh.length(),
           InstanceKlass::number_of_instance_classes(),
           Universe::heap()->used() / K,
           Universe::heap()->capacity() / K);
+  }
 
   fprintf(_log_fp, UINTX_FORMAT_W(6) ",", CodeCache::capacity() / K);
 
   fprintf(_log_fp, UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) ",%6ld\n",
           handles_memory_usage / K,
< prev index next >