Voi*_*son 31 java garbage-collection jmap
我一直在尝试jmap -histo和jmap -dump今天
按此顺序运行时
jmap -dump:format=b,file=heap.1 [pid]
jmap -dump:live,format=b,file=heap.2 [pid]
jmap -dump:format=b,file=heap.3 [pid]
Run Code Online (Sandbox Code Playgroud)
heap.3类似于heap.2不止heap.1.特别是,我感兴趣的"死"对象heap.1不存在heap.3.
看到这个,我开始寻找可以告诉我应该期待的文档.我最接近的是这次讨论,来自briand和alanb的评论意味着在实践中我可以预期当我使用live选项时会发生这个GC; 但答案是五年了,论坛上的帖子对于规范来说似乎有些不正式.
我在哪里可以找到记录的当前行为?
bes*_*sss 35
为了确定活跃性,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;
}
Run Code Online (Sandbox Code Playgroud)
在vmGCOperations.hpp中,这是定义
`VM_GC_HeapInspection(outputStream* out, bool request_full_gc,
bool need_prologue) :`
Run Code Online (Sandbox Code Playgroud)