有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么会发生Permgen OutOfMemory错误?

直到今天,我知道permgen空间有一些限制,当这个限制用尽时,OutOfMemoryError就来了,我认为这是正确的,因为我看到了OutOfMemoryErrorPermgen空间

但是Inside the Java Virtual Machine引用

The size of the method area need not be fixed. As the Java application runs, the virtual machine can expand and contract the method area to fit the application's needs.

那么,当JVM可以扩展时,为什么会出现错误呢?扩张有限制吗


共 (1) 个答案

  1. # 1 楼答案

    Method Area是较大的PermGen或非堆内存区域的一部分。PermSize设置修复了PermGen可以使用的最大内存。由于Method AreaPermGen的子部分,只要PermGen的总体大小保持在规定的限制范围内,它就可以根据需要扩展

    PermGen空间需求超出指定限制时(例如,由于扩展Method Area),抛出OutOfMemoryError