本文整理汇总了C++中SharedHeap::gc_epilogue方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedHeap::gc_epilogue方法的具体用法?C++ SharedHeap::gc_epilogue怎么用?C++ SharedHeap::gc_epilogue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedHeap
的用法示例。
在下文中一共展示了SharedHeap::gc_epilogue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: heap_inspection
void HeapInspection::heap_inspection(outputStream* st, bool need_prologue) {
ResourceMark rm;
HeapWord* ref;
CollectedHeap* heap = Universe::heap();
bool is_shared_heap = false;
switch (heap->kind()) {
case CollectedHeap::G1CollectedHeap:
case CollectedHeap::GenCollectedHeap: {
is_shared_heap = true;
SharedHeap* sh = (SharedHeap*)heap;
if (need_prologue) {
sh->gc_prologue(false /* !full */); // get any necessary locks, etc.
}
ref = sh->perm_gen()->used_region().start();
break;
}
#ifndef SERIALGC
case CollectedHeap::ParallelScavengeHeap: {
ParallelScavengeHeap* psh = (ParallelScavengeHeap*)heap;
ref = psh->perm_gen()->object_space()->used_region().start();
break;
}
#endif // SERIALGC
default:
ShouldNotReachHere(); // Unexpected heap kind for this op
}
// Collect klass instance info
KlassInfoTable cit(KlassInfoTable::cit_size, ref);
if (!cit.allocation_failed()) {
// Iterate over objects in the heap
RecordInstanceClosure ric(&cit);
// If this operation encounters a bad object when using CMS,
// consider using safe_object_iterate() which avoids perm gen
// objects that may contain bad references.
Universe::heap()->object_iterate(&ric);
// Report if certain classes are not counted because of
// running out of C-heap for the histogram.
size_t missed_count = ric.missed_count();
if (missed_count != 0) {
st->print_cr("WARNING: Ran out of C-heap; undercounted " SIZE_FORMAT
" total instances in data below",
missed_count);
}
// Sort and print klass instance info
KlassInfoHisto histo("\n"
" num #instances #bytes class name\n"
"----------------------------------------------",
KlassInfoHisto::histo_initial_size);
HistoClosure hc(&histo);
cit.iterate(&hc);
histo.sort();
histo.print_on(st);
} else {
st->print_cr("WARNING: Ran out of C-heap; histogram not generated");
}
st->flush();
if (need_prologue && is_shared_heap) {
SharedHeap* sh = (SharedHeap*)heap;
sh->gc_epilogue(false /* !full */); // release all acquired locks, etc.
}
}
示例2: epilogue
void HeapInspection::epilogue() {
if (is_shared_heap()) {
SharedHeap* sh = SharedHeap::heap();
sh->gc_epilogue(false /* !full */); // release all acquired locks, etc.
}
}