【发布时间】:2017-12-15 16:41:22
【问题描述】:
bool PSScavenge::invoke_no_policy()
...
if (GCLocker::check_active_before_gc()) {
return false;
}
...
如你所见,如果GCLocker::check_active_before_gc() 是true,它不会调用minor GC,即PSScavenge::invoke_no_policy()。为什么会这样?
check_active_before_gc()
bool GCLocker::check_active_before_gc() {
assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
if (is_active() && !_needs_gc) {
verify_critical_count();
_needs_gc = true;
log_debug_jni("Setting _needs_gc.");
}
return is_active();
}
is_active()
// Accessors
static bool is_active() {
assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
return is_active_internal();
}
is_active_internal()
static bool is_active_internal() {
verify_critical_count();
return _jni_lock_count > 0;
}
_jni_lock_count
static volatile jint _jni_lock_count; // number of jni active instances.
_jni_lock_count 跟踪正在运行的线程数
目前处于关键区域。
【问题讨论】:
标签: java garbage-collection jvm jvm-hotspot