comparison src/share/vm/services/threadService.cpp @ 1995:b1a2afa37ec4

7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis Summary: Track allocated bytes in Thread's, update on TLAB retirement and direct allocation in Eden and tenured, add JNI methods for ThreadMXBean. Reviewed-by: coleenp, kvn, dholmes, ysr
author phh
date Fri, 07 Jan 2011 10:42:32 -0500
parents f95d63e2154a
children 3582bf76420e
comparison
equal deleted inserted replaced
8:235b5114a673 9:7224cd5526cc
1 /* 1 /*
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
44 // - Hotspot extension (private/internal and uncommitted) 44 // - Hotspot extension (private/internal and uncommitted)
45 45
46 // Default is disabled. 46 // Default is disabled.
47 bool ThreadService::_thread_monitoring_contention_enabled = false; 47 bool ThreadService::_thread_monitoring_contention_enabled = false;
48 bool ThreadService::_thread_cpu_time_enabled = false; 48 bool ThreadService::_thread_cpu_time_enabled = false;
49 bool ThreadService::_thread_allocated_memory_enabled = false;
49 50
50 PerfCounter* ThreadService::_total_threads_count = NULL; 51 PerfCounter* ThreadService::_total_threads_count = NULL;
51 PerfVariable* ThreadService::_live_threads_count = NULL; 52 PerfVariable* ThreadService::_live_threads_count = NULL;
52 PerfVariable* ThreadService::_peak_threads_count = NULL; 53 PerfVariable* ThreadService::_peak_threads_count = NULL;
53 PerfVariable* ThreadService::_daemon_threads_count = NULL; 54 PerfVariable* ThreadService::_daemon_threads_count = NULL;
82 PerfData::U_None, CHECK); 83 PerfData::U_None, CHECK);
83 84
84 if (os::is_thread_cpu_time_supported()) { 85 if (os::is_thread_cpu_time_supported()) {
85 _thread_cpu_time_enabled = true; 86 _thread_cpu_time_enabled = true;
86 } 87 }
88
89 _thread_allocated_memory_enabled = true; // Always on, so enable it
87 } 90 }
88 91
89 void ThreadService::reset_peak_thread_count() { 92 void ThreadService::reset_peak_thread_count() {
90 // Acquire the lock to update the peak thread count 93 // Acquire the lock to update the peak thread count
91 // to synchronize with thread addition and removal. 94 // to synchronize with thread addition and removal.
175 bool ThreadService::set_thread_cpu_time_enabled(bool flag) { 178 bool ThreadService::set_thread_cpu_time_enabled(bool flag) {
176 MutexLocker m(Management_lock); 179 MutexLocker m(Management_lock);
177 180
178 bool prev = _thread_cpu_time_enabled; 181 bool prev = _thread_cpu_time_enabled;
179 _thread_cpu_time_enabled = flag; 182 _thread_cpu_time_enabled = flag;
183
184 return prev;
185 }
186
187 bool ThreadService::set_thread_allocated_memory_enabled(bool flag) {
188 MutexLocker m(Management_lock);
189
190 bool prev = _thread_allocated_memory_enabled;
191 _thread_allocated_memory_enabled = flag;
180 192
181 return prev; 193 return prev;
182 } 194 }
183 195
184 // GC support 196 // GC support