2

I am trying to read a simple 8 MB file with 2G heap memory using Apache POI. But I am getting 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

Below is the code that is generating the issue :

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

I dont think that this much memory is required for this operation, I know there are multiple questions asked on this, but I tried many things?

Amandeep Singh
  • 3,754
  • 8
  • 51
  • 72
  • For low memory reading of .xlsx files, please refer to http://stackoverflow.com/questions/12513981/reading-data-from-xlsx-with-apache-pois-sxssfsheet – diufanman Dec 14 '16 at 10:52
  • 2
    Read the docs and follow http://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api ? – Gagravarr Dec 14 '16 at 11:41

1 Answers1

1

use https://github.com/monitorjbl/excel-streaming-reader it solved my problem with large excel files

reference

How to load a large xlsx file with Apache POI?

Community
  • 1
  • 1
Elsayed
  • 2,712
  • 7
  • 28
  • 41