当前位置: 首页>>代码示例>>C++>>正文


C++ ParallelScavengeHeap::min_alignment方法代码示例

本文整理汇总了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());
  }
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:37,代码来源:psOldGen.cpp


注:本文中的ParallelScavengeHeap::min_alignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。