使用live选项时,jmap是否强制垃圾回收? [英] Does jmap force garbage collection when the live option is used?
问题描述
我一直在试用 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]
heap.3
类似于 heap.2
大于 heap.1
。特别是,我对 heap.1
感兴趣的死对象在 heap.3
。
看到这个,我开始寻找可以告诉我我应该期待什么的文档。我设法得到的最接近的是这个讨论,其中来自briand和alanb的评论意味着在实践中当我使用live选项时,我可以期待这个GC发生;但答案是五年,并且对论坛帖子看起来有点不正式。
我在哪里可以找到记录的当前行为?
$为了确定活跃性,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
//执行inspectheap 命令
//
//输入参数: -
// arg0:-live或-all
static jint heap_inspection(AttachOperation * op,outputStream * out ){
bool live_objects_only = true; //默认为true,以保持行为之前的行为
const char * arg0 = op-> arg(0); (arg0!= NULL&&(strlen(arg0)> 0)){
if(strcmp(arg0,-all)!= 0&& strcmp(arg0 ,-live)!= 0){
out-> print_cr(检查堆操作的无效参数:%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):`
I've been experimenting with jmap -histo
and jmap -dump
today
When run in this sequence
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]
heap.3
resembles heap.2
more than heap.1
. In particular, the "dead" objects that I'm interested in in heap.1
are absent from heap.3
.
Seeing this, I started looking for documentation that would tell me what I should expect. The closest I managed to get was this discussion, where the comments from briand and alanb imply that in practice I can expect this GC to occur when I use the live option; but the answers are five years old, and posts to a forum seem a bit informal for a specification.
Where can I find the current behavior documented?
In order to determine liveness, Java has to run full GC, so yes, it does.
To put the question to sleep... here is the answer, if anyone needs to dig deeper. Feel free.
part of /hotspot/agent/src/share/vm/services/attachListener.cpp taken from
openjdk http://download.java.net/openjdk/jdk7/ and you must accept 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;
}
in vmGCOperations.hpp it's the definition
`VM_GC_HeapInspection(outputStream* out, bool request_full_gc,
bool need_prologue) :`
这篇关于使用live选项时,jmap是否强制垃圾回收?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!