Jakarta ee 在Tomcat7中获得java堆空间问题

Jakarta ee 在Tomcat7中获得java堆空间问题,jakarta-ee,tomcat7,Jakarta Ee,Tomcat7,我正在开发一个JavaEEWeb应用程序,它由Struts、Spring和Hibernate组成。在这种情况下,我会反复出现以下异常(至少每天一次) 例外情况1: Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space at java.util.LinkedHashMap.createEntry(LinkedHashMap.java:424) at java.util.LinkedHash

我正在开发一个JavaEEWeb应用程序,它由Struts、Spring和Hibernate组成。在这种情况下,我会反复出现以下异常(至少每天一次)

例外情况1:

Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space
    at java.util.LinkedHashMap.createEntry(LinkedHashMap.java:424)
    at java.util.LinkedHashMap.addEntry(LinkedHashMap.java:406)
    at java.util.HashMap.put(HashMap.java:385)
    at sun.util.resources.OpenListResourceBundle.loadLookup(OpenListResourceBundle.java:118)
    at sun.util.resources.OpenListResourceBundle.loadLookupTablesIfNecessary(OpenListResourceBundle.java:97)
    at sun.util.resources.OpenListResourceBundle.handleGetObject(OpenListResourceBundle.java:58)
    at sun.util.resources.TimeZoneNamesBundle.handleGetObject(TimeZoneNamesBundle.java:59)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:368)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:371)
    at java.util.ResourceBundle.getStringArray(ResourceBundle.java:351)
    at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:100)
    at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:81)
    at java.util.TimeZone.getDisplayNames(TimeZone.java:399)
    at java.util.TimeZone.getDisplayName(TimeZone.java:350)
    at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1110)
    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:899)
    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:869)
    at java.text.DateFormat.format(DateFormat.java:316)
    at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:443)
    at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65)
    at org.apache.log4j.PatternLayout.format(PatternLayout.java:506)
    at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:310)
    at org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:369)
    at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
    at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
    at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
    at org.apache.log4j.Category.callAppenders(Category.java:206)
    at org.apache.log4j.Category.forcedLog(Category.java:391)
    at org.apache.log4j.Category.log(Category.java:856)
    at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.log(Log4jMLog.java:161)
    at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.warning(Log4jMLog.java:221)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector.run(ThreadPoolAsynchronousRunner.java:624)
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.util.HashMap.addEntry(HashMap.java:753)
    at java.util.HashMap.put(HashMap.java:385)
    at java.util.HashSet.add(HashSet.java:200)
    at com.mchange.v2.c3p0.util.ConnectionEventSupport.addConnectionEventListener(ConnectionEventSupport.java:39)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.addConnectionEventListener(NewPooledConnection.java:237)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishResourceOnCheckin(C3P0PooledConnectionPool.java:292)
    at com.mchange.v2.resourcepool.BasicResourcePool.attemptRefurbishResourceOnCheckin(BasicResourcePool.java:1606)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$200(BasicResourcePool.java:32)
    at com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask.run(BasicResourcePool.java:1228)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#4" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@6c8bb765" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#3" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@6c8bb765" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@6c8bb765" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space
Exception in thread ""http-bio-8080"-exec-2" java.lang.OutOfMemoryError: Java heap space
Exception in thread ""http-bio-8443"-Acceptor-0" java.lang.OutOfMemoryError: Java heap space
Exception in thread ""http-bio-8080"-exec-3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#4" java.lang.OutOfMemoryError: GC overhead limit exceeded
例外情况2:

Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space
    at java.util.LinkedHashMap.createEntry(LinkedHashMap.java:424)
    at java.util.LinkedHashMap.addEntry(LinkedHashMap.java:406)
    at java.util.HashMap.put(HashMap.java:385)
    at sun.util.resources.OpenListResourceBundle.loadLookup(OpenListResourceBundle.java:118)
    at sun.util.resources.OpenListResourceBundle.loadLookupTablesIfNecessary(OpenListResourceBundle.java:97)
    at sun.util.resources.OpenListResourceBundle.handleGetObject(OpenListResourceBundle.java:58)
    at sun.util.resources.TimeZoneNamesBundle.handleGetObject(TimeZoneNamesBundle.java:59)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:368)
    at java.util.ResourceBundle.getObject(ResourceBundle.java:371)
    at java.util.ResourceBundle.getStringArray(ResourceBundle.java:351)
    at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:100)
    at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:81)
    at java.util.TimeZone.getDisplayNames(TimeZone.java:399)
    at java.util.TimeZone.getDisplayName(TimeZone.java:350)
    at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1110)
    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:899)
    at java.text.SimpleDateFormat.format(SimpleDateFormat.java:869)
    at java.text.DateFormat.format(DateFormat.java:316)
    at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:443)
    at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65)
    at org.apache.log4j.PatternLayout.format(PatternLayout.java:506)
    at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:310)
    at org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:369)
    at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
    at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
    at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
    at org.apache.log4j.Category.callAppenders(Category.java:206)
    at org.apache.log4j.Category.forcedLog(Category.java:391)
    at org.apache.log4j.Category.log(Category.java:856)
    at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.log(Log4jMLog.java:161)
    at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.warning(Log4jMLog.java:221)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector.run(ThreadPoolAsynchronousRunner.java:624)
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.util.HashMap.addEntry(HashMap.java:753)
    at java.util.HashMap.put(HashMap.java:385)
    at java.util.HashSet.add(HashSet.java:200)
    at com.mchange.v2.c3p0.util.ConnectionEventSupport.addConnectionEventListener(ConnectionEventSupport.java:39)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.addConnectionEventListener(NewPooledConnection.java:237)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.refurbishResourceOnCheckin(C3P0PooledConnectionPool.java:292)
    at com.mchange.v2.resourcepool.BasicResourcePool.attemptRefurbishResourceOnCheckin(BasicResourcePool.java:1606)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$200(BasicResourcePool.java:32)
    at com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask.run(BasicResourcePool.java:1228)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#4" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@6c8bb765" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#3" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@6c8bb765" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Task-Thread-for-com.mchange.v2.async.ThreadPerTaskAsynchronousRunner@6c8bb765" java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "Timer-0" java.lang.OutOfMemoryError: Java heap space
Exception in thread ""http-bio-8080"-exec-2" java.lang.OutOfMemoryError: Java heap space
Exception in thread ""http-bio-8443"-Acceptor-0" java.lang.OutOfMemoryError: Java heap space
Exception in thread ""http-bio-8080"-exec-3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#4" java.lang.OutOfMemoryError: GC overhead limit exceeded
这是我的配置:

-server -Xms2048m -Xmx2048m
-XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:PermSize=512m
-XX:MaxPermSize=1024m -XX:+DisableExplicitGC"
任何人都可以指出,我得到这个例外是因为这种配置或任何其他

我知道我的代码中存在一些问题,但如何预测以发现这些问题? 我尝试过EclipseMat来分析内存转储,但没有任何想法

我已经尝试过增加这方面的内存,但除了减少这种异常的频率外,没有多大帮助


请帮忙。提前感谢。

关于为什么会出现这些异常,有两种选择。首先,您的应用程序可能只需要这么多内存。其次,应用程序会泄漏内存。无论哪种情况,MAT都是诊断问题的好工具。一个好的起点是支配树和泄漏可疑报告