在項目中,在子線程中出現:java.lang.OutOfMemoryError: GC overhead limit exceeded ,而是用exception進行沒法捕獲異常,由於屬於Error,因此只能是用Throwable進行捕獲。css
- java.lang.OutOfMemoryError: GC overhead limit exceeded
- at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1022)
- at org.apache.commons.io.IOUtils.copy(IOUtils.java:999)
- at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:218)
- at org.apache.commons.io.FileUtils.readFileToByteArray(FileUtils.java:995)
- ...........................
scheduledService = new ScheduledThreadPoolExecutor(1);
ReBuildJob job =
new
ReBuildJob();
job.setUncaughtExceptionHandler(
new
UncaughtExceptionHandler(){
@Override
public
void
uncaughtException(Thread t, Throwable e) {
logger
.error(
"Thread down, name:'{}', Exception {}"
,t.getName(), e);
}
});
scheduledService
.scheduleAtFixedRate(job, UnicornConstant.
TIMER_DELAY
,
UnicornConstant.
TIMER_INTERVAL
, TimeUnit.
MILLISECONDS
);
|
for
(File file : cssFiles) {
try
{
iteratorHandle(resourceReader, file, versionList);
}
catch
(Throwable e) {
logger
.error(
"Note: load css file '{}' exception, {}"
, file, e);
}
}
|
其餘建議:html
1、異常以下:
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceededjava
2、解釋:
JDK6新增錯誤類型。當GC爲釋放很小空間佔用大量時間時拋出。
通常是由於堆過小。致使異常的緣由:沒有足夠的內存。apache
3、解決方案:ide
一、查看系統是否有使用大內存的代碼或死循環。
二、能夠添加JVM的啓動參數來限制使用內存:-XX:-UseGCOverheadLimitpost