当 运行 作为服务时,permgen space 内存不足

Out of memory permgen space when running as service

我有 Jboss 7.1.1 AS,当我 运行 它作为服务时,一段时间后,当我使用 jasper 报告时,我得到异常:java.lang.OutOfMemoryError: PermGen space

请注意,当我从 Jboss developer studio 运行 它时,这根本不会发生。

我该怎么办?

错误堆栈:

at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.7.0_79]
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585) [rt.jar:1.7.0_79]
    at java.lang.Class.getConstructor0(Class.java:2885) [rt.jar:1.7.0_79]
    at java.lang.Class.newInstance(Class.java:350) [rt.jar:1.7.0_79]
    at sun.reflect.MethodAccessorGenerator.run(MethodAccessorGenerator.java:399) [rt.jar:1.7.0_79]
    at sun.reflect.MethodAccessorGenerator.run(MethodAccessorGenerator.java:396) [rt.jar:1.7.0_79]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_79]
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:395) [rt.jar:1.7.0_79]
    at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:113) [rt.jar:1.7.0_79]
    at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:331) [rt.jar:1.7.0_79]
    at java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1376) [rt.jar:1.7.0_79]
    at java.io.ObjectStreamClass.access00(ObjectStreamClass.java:72) [rt.jar:1.7.0_79]
    at java.io.ObjectStreamClass.run(ObjectStreamClass.java:493) [rt.jar:1.7.0_79]
    at java.io.ObjectStreamClass.run(ObjectStreamClass.java:468) [rt.jar:1.7.0_79]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_79]
    at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:468) [rt.jar:1.7.0_79]
    at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:365) [rt.jar:1.7.0_79]
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:602) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1622) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350) [rt.jar:1.7.0_79]
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370) [rt.jar:1.7.0_79]
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:249) [jasperreports-5.6.1.jar:5.6.1]
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:233) [jasperreports-5.6.1.jar:5.6.1]
    at net.sf.jasperreports.repo.SerializedObjectPersistenceService.load(SerializedObjectPersistenceService.java:59) [jasperreports-5.6.1.jar:5.6.1]
    at net.sf.jasperreports.repo.SerializedReportPersistenceService.load(SerializedReportPersistenceService.java:43) [jasperreports-5.6.1.jar:5.6.1]
    at net.sf.jasperreports.repo.DefaultRepositoryService.getResource(DefaultRepositoryService.java:155) [jasperreports-5.6.1.jar:5.6.1]

您可以尝试在服务器的 bin 文件夹内的 standalone.conf.bat 中为您的 JBoss 提高 PermSize

找到集合“JAVA_OPTS=-Xms64M -Xmx512M -XX:MaxPermSize=256M”并根据您的要求更改 MaxPermSize

我不太了解 developer studio,但它可能会为服务器设置 PermGem 并忽略 standalone.conf.bat(具有更高的值),因此您的报告有效。

但是,您需要在报告中搜索可能导致 OutOfMemoryError.

的任何漏洞

希望对您有所帮助。