gpt4 book ai didi

java - 为什么 PermGen 空间在增长?

转载 作者:太空狗 更新时间:2023-10-29 22:38:04 27 4
gpt4 key购买 nike

我读了几篇文章,我理解了以下内容(如果我错了,请纠正我和/或编辑问题):

java堆是这样分割的:

  • Young Generation:创建的对象放在这里,这部分被频繁且廉价地垃圾收集

  • Old Generation:在 Young generation 的垃圾收集中幸存下来的对象放在这里,这个区域的垃圾收集频率较低,并且使用对 CPU 要求更高的进程/算法(我相信它称为标记清除)

编辑:正如另一位用户所述,PermGen 不是名为 heap 的区域的一部分

  • PermGen:此区域包含您的应用类元数据和许多其他不依赖于应用使用情况的内容。

那么,知道这一点……为什么我的 PermGen 空间会在应用程序负载很重时增长?对于我之前所说的,尽管有应用程序负载,这个空间不应该逐渐填充,但正如我在开始时所说的那样,我可能对某些假设是错误的。

事实上,如果 PermGen 空间在增长,是否有垃圾收集或重置的方法?

最佳答案

实际上,在 Sun 的 JVM 中永久代(PermGen)是完全独立于堆的。你确定你不是在看Tenured Generation吗?如果你的 Permanent Generation 一直在增长,那确实是值得怀疑的。

如果您的 perm gen 不断增长,那么这是一个很难深入的领域。通常它应该在第一次加载新类时增长(并且可能某些反射的使用也可能导致这种情况)。 Interned 字符串也存储在 perm gen 中。

如果您碰巧在 Solaris 上,您可以使用 jmap -permstat 来转储 perm gen 统计信息,但该选项在 Windows(以及其他可能的平台)上似乎不可用。这是 the documentation on jmap for Java 6

来自Sun的guide on JConsole (这将让您查看这些池的大小):

For the HotSpot Java VM, the memory pools for serial garbage collection are the following.

  • Eden Space (heap): The pool from which memory is initially allocated for most objects.
  • Survivor Space (heap): The pool containing objects that have survived the garbage collection of the Eden space.
  • Tenured Generation (heap): The pool containing objects that have existed for some time in the survivor space.
  • Permanent Generation (non-heap): The pool containing all the reflective data of the virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas.
  • Code Cache (non-heap): The HotSpot Java VM also includes a code cache, containing memory that is used for compilation and storage of native code.

关于java - 为什么 PermGen 空间在增长?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2051734/

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