66 int MemTracker::_sync_point_skip_count = 0; 67 MemTracker::NMTLevel MemTracker::_tracking_level = MemTracker::NMT_off; 68 volatile MemTracker::NMTStates MemTracker::_state = NMT_uninited; 69 MemTracker::ShutdownReason MemTracker::_reason = NMT_shutdown_none; 70 int MemTracker::_thread_count = 255; 71 volatile jint MemTracker::_pooled_recorder_count = 0; 72 volatile unsigned long MemTracker::_processing_generation = 0; 73 volatile bool MemTracker::_worker_thread_idle = false; 74 volatile jint MemTracker::_pending_op_count = 0; 75 volatile bool MemTracker::_slowdown_calling_thread = false; 76 debug_only(intx MemTracker::_main_thread_tid = 0;) 77 NOT_PRODUCT(volatile jint MemTracker::_pending_recorder_count = 0;) 78 79 void MemTracker::init_tracking_options(const char* option_line) { 80 _tracking_level = NMT_off; 81 if (strcmp(option_line, "=summary") == 0) { 82 _tracking_level = NMT_summary; 83 } else if (strcmp(option_line, "=detail") == 0) { 84 // detail relies on a stack-walking ability that may not 85 // be available depending on platform and/or compiler flags 86 if (PLATFORM_NMT_DETAIL_SUPPORTED) { 87 _tracking_level = NMT_detail; 88 } else { 89 jio_fprintf(defaultStream::error_stream(), 90 "NMT detail is not supported on this platform. Using NMT summary instead.\n"); 91 _tracking_level = NMT_summary; 92 } 93 } else if (strcmp(option_line, "=off") != 0) { 94 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL); 95 } 96 } 97 98 // first phase of bootstrapping, when VM is still in single-threaded mode. 99 void MemTracker::bootstrap_single_thread() { 100 if (_tracking_level > NMT_off) { 101 assert(_state == NMT_uninited, "wrong state"); 102 103 // NMT is not supported with UseMallocOnly is on. NMT can NOT 104 // handle the amount of malloc data without significantly impacting 105 // runtime performance when this flag is on. 106 if (UseMallocOnly) { 107 shutdown(NMT_use_malloc_only); 108 return; 109 } 110 111 _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock"); 112 if (_query_lock == NULL) { | 66 int MemTracker::_sync_point_skip_count = 0; 67 MemTracker::NMTLevel MemTracker::_tracking_level = MemTracker::NMT_off; 68 volatile MemTracker::NMTStates MemTracker::_state = NMT_uninited; 69 MemTracker::ShutdownReason MemTracker::_reason = NMT_shutdown_none; 70 int MemTracker::_thread_count = 255; 71 volatile jint MemTracker::_pooled_recorder_count = 0; 72 volatile unsigned long MemTracker::_processing_generation = 0; 73 volatile bool MemTracker::_worker_thread_idle = false; 74 volatile jint MemTracker::_pending_op_count = 0; 75 volatile bool MemTracker::_slowdown_calling_thread = false; 76 debug_only(intx MemTracker::_main_thread_tid = 0;) 77 NOT_PRODUCT(volatile jint MemTracker::_pending_recorder_count = 0;) 78 79 void MemTracker::init_tracking_options(const char* option_line) { 80 _tracking_level = NMT_off; 81 if (strcmp(option_line, "=summary") == 0) { 82 _tracking_level = NMT_summary; 83 } else if (strcmp(option_line, "=detail") == 0) { 84 // detail relies on a stack-walking ability that may not 85 // be available depending on platform and/or compiler flags 86 #if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED 87 _tracking_level = NMT_detail; 88 #else 89 jio_fprintf(defaultStream::error_stream(), 90 "NMT detail is not supported on this platform. Using NMT summary instead.\n"); 91 _tracking_level = NMT_summary; 92 #endif 93 } else if (strcmp(option_line, "=off") != 0) { 94 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL); 95 } 96 } 97 98 // first phase of bootstrapping, when VM is still in single-threaded mode. 99 void MemTracker::bootstrap_single_thread() { 100 if (_tracking_level > NMT_off) { 101 assert(_state == NMT_uninited, "wrong state"); 102 103 // NMT is not supported with UseMallocOnly is on. NMT can NOT 104 // handle the amount of malloc data without significantly impacting 105 // runtime performance when this flag is on. 106 if (UseMallocOnly) { 107 shutdown(NMT_use_malloc_only); 108 return; 109 } 110 111 _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock"); 112 if (_query_lock == NULL) { |