本文整理汇总了C++中GenCollectedHeap::gen_policy方法的典型用法代码示例。如果您正苦于以下问题:C++ GenCollectedHeap::gen_policy方法的具体用法?C++ GenCollectedHeap::gen_policy怎么用?C++ GenCollectedHeap::gen_policy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenCollectedHeap
的用法示例。
在下文中一共展示了GenCollectedHeap::gen_policy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute_new_size
void ASParNewGeneration::compute_new_size() {
GenCollectedHeap* gch = GenCollectedHeap::heap();
assert(gch->kind() == CollectedHeap::GenCollectedHeap,
"not a CMS generational heap");
CMSAdaptiveSizePolicy* size_policy =
(CMSAdaptiveSizePolicy*)gch->gen_policy()->size_policy();
assert(size_policy->is_gc_cms_adaptive_size_policy(),
"Wrong type of size policy");
size_t survived = from()->used();
if (!survivor_overflow()) {
// Keep running averages on how much survived
size_policy->avg_survived()->sample(survived);
} else {
size_t promoted =
(size_t) next_gen()->gc_stats()->avg_promoted()->last_sample();
assert(promoted < gch->capacity(), "Conversion problem?");
size_t survived_guess = survived + promoted;
size_policy->avg_survived()->sample(survived_guess);
}
size_t survivor_limit = max_survivor_size();
_tenuring_threshold =
size_policy->compute_survivor_space_size_and_threshold(
_survivor_overflow,
_tenuring_threshold,
survivor_limit);
size_policy->avg_young_live()->sample(used());
size_policy->avg_eden_live()->sample(eden()->used());
size_policy->compute_young_generation_free_space(eden()->capacity(),
max_gen_size());
resize(size_policy->calculated_eden_size_in_bytes(),
size_policy->calculated_survivor_size_in_bytes());
if (UsePerfData) {
CMSGCAdaptivePolicyCounters* counters =
(CMSGCAdaptivePolicyCounters*) gch->collector_policy()->counters();
assert(counters->kind() ==
GCPolicyCounters::CMSGCAdaptivePolicyCountersKind,
"Wrong kind of counters");
counters->update_tenuring_threshold(_tenuring_threshold);
counters->update_survivor_overflowed(_survivor_overflow);
counters->update_young_capacity(capacity());
}
}
示例2: collect
//.........这里部分代码省略.........
&fsc_with_no_gc_barrier,
&fsc_with_gc_barrier);
assert(gch->no_allocs_since_save_marks(0),
"save marks have not been newly set.");
int so = SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_CodeCache;
gch->gen_process_strong_roots(_level,
true, // Process younger gens, if any,
// as strong roots.
true, // activate StrongRootsScope
true, // is scavenging
SharedHeap::ScanningOption(so),
&fsc_with_no_gc_barrier,
true, // walk *all* scavengable nmethods
&fsc_with_gc_barrier,
&klass_scan_closure);
// "evacuate followers".
evacuate_followers.do_void();
FastKeepAliveClosure keep_alive(this, &scan_weak_ref);
ReferenceProcessor* rp = ref_processor();
rp->setup_policy(clear_all_soft_refs);
const ReferenceProcessorStats& stats =
rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers,
NULL, _gc_timer);
gc_tracer.report_gc_reference_stats(stats);
if (!_promotion_failed) {
// Swap the survivor spaces.
eden()->clear(SpaceDecorator::Mangle);
from()->clear(SpaceDecorator::Mangle);
if (ZapUnusedHeapArea) {
// This is now done here because of the piece-meal mangling which
// can check for valid mangling at intermediate points in the
// collection(s). When a minor collection fails to collect
// sufficient space resizing of the young generation can occur
// an redistribute the spaces in the young generation. Mangle
// here so that unzapped regions don't get distributed to
// other spaces.
to()->mangle_unused_area();
}
swap_spaces();
assert(to()->is_empty(), "to space should be empty now");
adjust_desired_tenuring_threshold();
// A successful scavenge should restart the GC time limit count which is
// for full GC's.
AdaptiveSizePolicy* size_policy = gch->gen_policy()->size_policy();
size_policy->reset_gc_overhead_limit_count();
if (PrintGC && !PrintGCDetails) {
gch->print_heap_change(gch_prev_used);
}
assert(!gch->incremental_collection_failed(), "Should be clear");
} else {
assert(_promo_failure_scan_stack.is_empty(), "post condition");
_promo_failure_scan_stack.clear(true); // Clear cached segments.
remove_forwarding_pointers();
if (PrintGCDetails) {
gclog_or_tty->print(" (promotion failed) ");
}
// Add to-space to the list of space to compact
// when a promotion failure has occurred. In that
// case there can be live objects in to-space
// as a result of a partial evacuation of eden
// and from-space.
swap_spaces(); // For uniformity wrt ParNewGeneration.
from()->set_next_compaction_space(to());
gch->set_incremental_collection_failed();
// Inform the next generation that a promotion failure occurred.
_next_gen->promotion_failure_occurred();
gc_tracer.report_promotion_failed(_promotion_failed_info);
// Reset the PromotionFailureALot counters.
NOT_PRODUCT(Universe::heap()->reset_promotion_should_fail();)
}
// set new iteration safe limit for the survivor spaces
from()->set_concurrent_iteration_safe_limit(from()->top());
to()->set_concurrent_iteration_safe_limit(to()->top());
SpecializationStats::print();
// We need to use a monotonically non-decreasing time in ms
// or we will see time-warp warnings and os::javaTimeMillis()
// does not guarantee monotonicity.
jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
update_time_of_last_gc(now);
gch->trace_heap_after_gc(&gc_tracer);
gc_tracer.report_tenuring_threshold(tenuring_threshold());
_gc_timer->register_gc_end();
gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
}