Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的应用程序启动时,我正在创建容量为 75*10^6 的 trove long hash set。
Profiler 显示,该应用程序使用 1.4g。我正在尝试设置-Xmx1600m,然后内存不足。
-Xmx2000m 相同。
-Xmx2030m 相同。
-Xmx2040m 好的。
Profiler 没有看到这么大的分配,它在哪里以及为什么会发生?
很可能你的终身空间不够大。jvm 可能不够聪明,无法缩小其他区域以允许您使用如此大的连续块。注意 CMS 不会进行碎片整理,因此您可以使用更小的数组来解决这个问题。
对于这么大的集合,您可能会考虑使用堆外内存。