Tuesday, October 25, 2016

Apache POI is a Memory Pig

We get this stacktrace


java.lang.OutOfMemoryError: Java heap space
 at java.util.Arrays.copyOf(Arrays.java:2271)
 at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:191)
 at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource$FakeZipEntry.(ZipInputStreamZipEntrySource.java:132)
 at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.(ZipInputStreamZipEntrySource.java:55)
 at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:88)
 at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:273)



This even processing relatively small (10 MB) Excel files.
It seems that we are not alone on this Planet to experience this problem. And there doesn't seem to be a workaround, apart increasing heap, for lack of a Streaming Interface.

No comments: