开发者社区 问答 正文

怎么判定是否集合溢出呢?

怎么判定是否集合溢出呢?

展开
收起
游客fbdr25iajcjto 2021-12-06 21:45:47 759 分享 版权
1 条回答
写回答
取消 提交回答
  • maybeSpillCollection判定集合是否溢出主要由maybeSpill函数来决定,maybeSpill函数的处理步骤如下:

    1) 为当前线程尝试获取amountToRequest大小的内存(amountToRequest = 2 * currentMemory - myMemoryThreshold)。

    2) 如果获得的内存依然不足(myMemoryThreshold <= currentMemory),则调用spill,执行溢出操作。内存不足可能是申请到的内存为0或者已经申请得到的内存大小超过了myMemoryThreshold。

    3) 溢出后续处理,如elementsRead归零,已溢出内存字节数(memoryBytesSpilled)增加线程当前内存大小(currentMemory),释放当前线程占用的内存。

    2021-12-06 21:46:31
    赞同 展开评论
问答地址: