为了确定活动性,Java必须运行完整的GC,所以是的,它确实如此。
让问题入睡...这是答案,如果有人需要深入挖掘。随意。
部分 /hotspot/agent/src/share/vm/services/attachListener.cpp取自
openjdk http://download.java.net/openjdk/jdk7/,你必须接受 http://www.gnu.org/licenses/gpl-2.0.html
// Implementation of "inspectheap" command
//
// Input arguments :-
// arg0: "-live" or "-all"
static jint heap_inspection(AttachOperation* op, outputStream* out) {
bool live_objects_only = true; // default is true to retain the behavior before this change is made
const char* arg0 = op->arg(0);
if (arg0 != NULL && (strlen(arg0) > 0)) {
if (strcmp(arg0, "-all") != 0 && strcmp(arg0, "-live") != 0) {
out->print_cr("Invalid argument to inspectheap operation: %s", arg0);
return JNI_ERR;
}
live_objects_only = strcmp(arg0, "-live") == 0;
}
VM_GC_HeapInspection heapop(out, live_objects_only /* request full gc */, true /* need_prologue */);
VMThread::execute(&heapop);
return JNI_OK;
}
在 vmGCOperations.hpp 中,这是定义
`VM_GC_HeapInspection(outputStream* out, bool request_full_gc,
bool need_prologue) :`