gpt4 book ai didi

java - 保持 MaxPermSize 较小有什么好处吗?

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:50:41 25 4
gpt4 key购买 nike

假设一个 64 位 JVM,保持 MaxPermSize 小有什么显着的好处吗?

这是在频繁重新部署的 Java EE 应用程序的上下文中,并且存在类加载器泄漏。作为一个中期解决方法,将 MaxPermSize 增加到一个荒谬的值似乎是非常合理的 - 只要它不会耗尽磁盘交换空间。

因为未部署的应用程序的代码几乎全部未使用(除了泄漏中涉及的代码),它被操作系统调出页面。因此,未部署的碎屑对物理内存的负载似乎可以忽略不计;这已通过观察 RSS(Unix 上的工作集大小)得到验证。

我应该关注其他影响吗?

最佳答案

来自 JVM HotSpot FAQ

Should I increase the size of the permanent generation in the client vm?

This will always be a judgment call. In general increasing the size of a generation (and this applies not just to the permanent generation) can reduce the incidence of a wide variety of problems However, this may cause other processes to excessively page and/or garbage collect or throw out-of-memory exceptions.

There are two failure modes to consider.

When raising MaxPermSize, it is possible that previously well behaved programs that used to garbage collect to recover the permanent generation space will die by endless paging. For the permanent generation this usually only happens with the heavy interning of temporary strings.

The other failure mode is that address space must be reserved for the permanent generation and this will reduce that available for the rest of the heap (the maximum -Xmx may then be too large). This will cause programs configured to use all available space to fail at initialization.

还有 this article说:

So we take advantage of the fact that classes are kept in the permanent generation by collecting the permanent generation before collecting the tenured generation. And the permanent generation is currently collected serially.

我认为大型永久代会导致更长的 GC 时间。

关于java - 保持 MaxPermSize 较小有什么好处吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9636328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com