-
Notifications
You must be signed in to change notification settings - Fork 348
Open
Description
Hi guys,
I am unable to read large Excel files.
I am using the below code to fetch the workbook:
StreamingReader.builder()
.rowCacheSize(100)
.bufferSize(4096)
.open(inputStreamSupplier.get());
It is failing with below error :
java.lang.OutOfMemoryError: Requested array size exceeds VM limit
at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
at java.base/java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:100)
at java.base/java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:130)
at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:185)
at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:149)
at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:136)
at org.apache.poi.openxml4j.util.ZipArchiveFakeEntry.<init>(ZipArchiveFakeEntry.java:47)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.<init>(ZipInputStreamZipEntrySource.java:53)
at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:210)
at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:194)
at org.apache.poi.openxml4j.opc.ZipPackage.openZipEntrySourceStream(ZipPackage.java:168)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:149)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:277)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:186)
at com.monitorjbl.xlsx.impl.StreamingWorkbookReader.init(StreamingWorkbookReader.java:113)
at com.monitorjbl.xlsx.impl.StreamingWorkbookReader.init(StreamingWorkbookReader.java:91)
at com.monitorjbl.xlsx.StreamingReader$Builder.open(StreamingReader.java:251)
The memory assigned is 8GB, but it is still failing with this error. By observing the stack trace and also the heap dump, I noticed that we are creating a byte array with the total size of around 2.1GB.
How can we fix this issue?
Metadata
Metadata
Assignees
Labels
No labels