7003271: Hotspot should track cumulative Java heap bytes allocated on a per-thread basis

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
This commit is contained in:
Paul Hohensee 2011-01-07 10:42:32 -05:00
parent 6f2c2c3272
commit 7b0134a7cb
26 changed files with 447 additions and 212 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2011, 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
@ -46,6 +46,7 @@
// Default is disabled.
bool ThreadService::_thread_monitoring_contention_enabled = false;
bool ThreadService::_thread_cpu_time_enabled = false;
bool ThreadService::_thread_allocated_memory_enabled = false;
PerfCounter* ThreadService::_total_threads_count = NULL;
PerfVariable* ThreadService::_live_threads_count = NULL;
@ -84,6 +85,8 @@ void ThreadService::init() {
if (os::is_thread_cpu_time_supported()) {
_thread_cpu_time_enabled = true;
}
_thread_allocated_memory_enabled = true; // Always on, so enable it
}
void ThreadService::reset_peak_thread_count() {
@ -181,6 +184,15 @@ bool ThreadService::set_thread_cpu_time_enabled(bool flag) {
return prev;
}
bool ThreadService::set_thread_allocated_memory_enabled(bool flag) {
MutexLocker m(Management_lock);
bool prev = _thread_allocated_memory_enabled;
_thread_allocated_memory_enabled = flag;
return prev;
}
// GC support
void ThreadService::oops_do(OopClosure* f) {
for (ThreadDumpResult* dump = _threaddump_list; dump != NULL; dump = dump->next()) {