2016-12-14 375 views
0

我正在尝试使用Apache POI读取具有2G堆内存的简单8 MB文件。 但我得到以下例外。获取java.lang.OutOfMemoryError:读取excel文件时超出了GC开销限制

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); 

我不认为这么多内存需要这个手术,我知道有问这个多的问题,但我想很多东西?

+0

有关的.xlsx文件低内存读取,请参考http://stackoverflow.com/questions/12513981/reading-data-from-xlsx-with-apache-pois-sxssfsheet – diufanman

+1

阅读文档并遵循http://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api? – Gagravarr

回答

相关问题