本文整理汇总了C++中ParallelScavengeHeap::min_alignment方法的典型用法代码示例。如果您正苦于以下问题:C++ ParallelScavengeHeap::min_alignment方法的具体用法?C++ ParallelScavengeHeap::min_alignment怎么用?C++ ParallelScavengeHeap::min_alignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParallelScavengeHeap
的用法示例。
在下文中一共展示了ParallelScavengeHeap::min_alignment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resize
void PSOldGen::resize(size_t desired_free_space) {
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
const size_t alignment = heap->min_alignment();
const size_t size_before = _virtual_space.committed_size();
size_t new_size = used_in_bytes() + desired_free_space;
new_size = align_size_up(new_size, alignment);
assert(_max_gen_size == reserved().byte_size(), "max new size problem?");
// Adjust according to our min and max
new_size = MAX2(MIN2(new_size, _max_gen_size), _min_gen_size);
const size_t current_size = capacity_in_bytes();
if (new_size == current_size) {
// No change requested
return;
}
if (new_size > current_size) {
size_t change_bytes = new_size - current_size;
expand(change_bytes);
} else {
size_t change_bytes = current_size - new_size;
// shrink doesn't grab this lock, expand does. Is that right?
MutexLocker x(ExpandHeap_lock);
shrink(change_bytes);
}
if (PrintAdaptiveSizePolicy) {
gclog_or_tty->print_cr("AdaptiveSizePolicy::old generation size: "
"collection: %d "
"(" SIZE_FORMAT ") -> (" SIZE_FORMAT ") ",
heap->total_collections(),
size_before, _virtual_space.committed_size());
}
}