获取java.lang.OutOfMemoryError:读取excel文件时超出了GC开销限制

问题描述 投票:2回答:1

我试图使用Apache POI读取带有2G堆内存的简单8 MB文件。但我得到OutOfMemoryError

14:53:20,437 ERROR [stderr] (server-timer) java.lang.OutOfMemoryError: GC overhead limit exceeded
14:53:20,438 ERROR [stderr] (server-timer)      at java.util.HashMap.newKeyIterator(HashMap.java:968)
14:53:20,439 ERROR [stderr] (server-timer)      at java.util.HashMap$KeySet.iterator(HashMap.java:1002)
14:53:20,439 ERROR [stderr] (server-timer)      at java.util.HashSet.iterator(HashSet.java:170)
14:53:20,440 ERROR [stderr] (server-timer)      at java.util.Collections$SynchronizedCollection.iterator(Collections.java:1632)
14:53:20,441 ERROR [stderr] (server-timer)      at org.jboss.sun.net.httpserver.ServerImpl$ServerTimerTask.run(ServerImpl.java:844)
14:53:20,441 ERROR [stderr] (server-timer)      at java.util.TimerThread.mainLoop(Timer.java:555)
14:53:20,442 ERROR [stderr] (server-timer)      at java.util.TimerThread.run(Timer.java:505)
14:53:20,442 ERROR [stderr] (DataImportFeedEngine-1) java.lang.OutOfMemoryError: GC overhead limit exceeded
14:53:20,443 ERROR [stderr] (ContainerBackgroundProcessor[StandardEngine[jboss.web]]) java.lang.OutOfMemoryError: GC overhead limit exceeded
14:53:20,444 ERROR [stderr] (cluster-ClusterId{value='58510c2638359c3ff495fb11', description='null'}-localhost:27017) java.lang.OutOfMemoryError: GC overhead limit exceeded
14:53:20,445 ERROR [stderr] (pool-3-thread-1) java.lang.OutOfMemoryError: GC overhead limit exceeded
14:53:20,446 ERROR [stderr] (pool-3-thread-1)   at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.addConditionWaiter(AbstractQueuedSynchronizer.java:1857)
14:53:20,447 ERROR [stderr] (pool-3-thread-1)   at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2073)
14:53:20,448 ERROR [stderr] (pool-3-thread-1)   at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
14:53:20,448 ERROR [stderr] (pool-3-thread-1)   at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
14:53:20,449 ERROR [stderr] (pool-3-thread-1)   at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
14:53:20,452 ERROR [stderr] (pool-3-thread-1)   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
14:53:20,453 ERROR [stderr] (pool-3-thread-1)   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
14:53:20,453 ERROR [stderr] (pool-3-thread-1)   at java.lang.Thread.run(Thread.java:745)
14:53:20,454 ERROR [stderr] (pool-2-thread-1) java.lang.OutOfMemoryError: GC overhead limit exceeded
14:53:20,455 ERROR [stderr] (pool-4-thread-1) java.lang.OutOfMemoryError: GC overhead limit exceeded

以下是生成问题的代码:

  FileInputStream file = new FileInputStream(new File(srcFileName));
  XSSFWorkbook workbook = new XSSFWorkbook(file);
  XSSFSheet sheet = workbook.getSheetAt(0);

我不认为这个操作需要这么多内存,我知道有很多问题要问这个,但我尝试了很多东西?

java memory-management apache-poi
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.