I have a Java 7 application using JVM ARGS: -Xms1024m -Xmx2048m
, and it runs pretty well.
我有一个使用JVM ARGS: -Xms1024m -Xmx2048m的Java 7应用程序,它运行得很好。
After I upgrade to Java 8, it runs in error state with Exception:
在我升级到Java 8之后,它运行在错误状态,但有例外:
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.hibernate.engine.StatefulPersistenceContext.addEntry(StatefulPersistenceContext.java:466)
at org.hibernate.engine.TwoPhaseLoad.postHydrate(TwoPhaseLoad.java:80)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1439)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1332)
at org.hibernate.loader.Loader.getRow(Loader.java:1230)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
I'm wondering whether JVM ARGS -Xms1024m -Xmx2048m
is still working?
我想知道JVM ARGS -Xms1024m -Xmx2048m是否还在工作?
Since Java 8 has removed Perm Generation: http://www.infoq.com/articles/Java-PERMGEN-Removed, I think the different GC strategy/memory management between Java 7 and Java 8 may be the root cause. Is there any suggestion?
由于Java 8已经删除了Perm生成:http://www.infoq.com/articles/java - permgen,我认为Java 7和Java 8之间不同的GC策略/内存管理可能是根本原因。有什么建议吗?
3 个解决方案
#1
16
Due to PermGen removal some options were removed (like -XX:MaxPermSize
), but options -Xms
and -Xmx
work in Java 8. It's possible that under Java 8 your application simply needs somewhat more memory. Try to increase -Xmx
value. Alternatively you can try to switch to G1 garbage collector using -XX:+UseG1GC
.
由于PermGen的删除,一些选项被删除(比如-XX:MaxPermSize),但是选项-Xms和-Xmx在Java 8中工作。在Java 8下,您的应用程序可能只需要更多的内存。尝试增加-Xmx值。您也可以尝试使用-XX:+UseG1GC切换到G1垃圾收集器。
Note that if you use any option which was removed in Java 8, you will see a warning upon application start:
注意,如果您使用Java 8中删除的任何选项,您将在应用程序启动时看到一个警告:
$ java -XX:MaxPermSize=128M -version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
#2
2
What I know is one reason when “GC overhead limit exceeded” error is thrown when 2% of the memory is freed after several GC cycles
我所知道的是,当在几个GC循环之后释放2%的内存时,“GC开销限制超出”错误被抛出的原因之一
By this error your JVM is signalling that your application is spending too much time in garbage collection. so the little amount GC was able to clean will be quickly filled again thus forcing GC to restart the cleaning process again.
由于这个错误,JVM表明应用程序在垃圾收集中花费了太多时间。因此,GC能够清理的少量内容将很快被再次填充,从而迫使GC重新启动清理过程。
You should try changing the value of -Xmx
and -Xms
.
您应该尝试更改-Xmx和-Xms的值。
#3
-6
put same value for both -Xmx and -Xms
对-Xmx和-Xms都输入相同的值
#1
16
Due to PermGen removal some options were removed (like -XX:MaxPermSize
), but options -Xms
and -Xmx
work in Java 8. It's possible that under Java 8 your application simply needs somewhat more memory. Try to increase -Xmx
value. Alternatively you can try to switch to G1 garbage collector using -XX:+UseG1GC
.
由于PermGen的删除,一些选项被删除(比如-XX:MaxPermSize),但是选项-Xms和-Xmx在Java 8中工作。在Java 8下,您的应用程序可能只需要更多的内存。尝试增加-Xmx值。您也可以尝试使用-XX:+UseG1GC切换到G1垃圾收集器。
Note that if you use any option which was removed in Java 8, you will see a warning upon application start:
注意,如果您使用Java 8中删除的任何选项,您将在应用程序启动时看到一个警告:
$ java -XX:MaxPermSize=128M -version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
#2
2
What I know is one reason when “GC overhead limit exceeded” error is thrown when 2% of the memory is freed after several GC cycles
我所知道的是,当在几个GC循环之后释放2%的内存时,“GC开销限制超出”错误被抛出的原因之一
By this error your JVM is signalling that your application is spending too much time in garbage collection. so the little amount GC was able to clean will be quickly filled again thus forcing GC to restart the cleaning process again.
由于这个错误,JVM表明应用程序在垃圾收集中花费了太多时间。因此,GC能够清理的少量内容将很快被再次填充,从而迫使GC重新启动清理过程。
You should try changing the value of -Xmx
and -Xms
.
您应该尝试更改-Xmx和-Xms的值。
#3
-6
put same value for both -Xmx and -Xms
对-Xmx和-Xms都输入相同的值