Creating ZIP archives in Google App Engine (Java) <br />
I am got this error in the gae cloud logs: <br>
java.lang.OutOfMemoryError: Java heap space <br>
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
<br><br>I face this problem when zipping many files on the production server,
so what should I do to fix it ? is there something can help in GAE
or can I save zip file containing one file on the storage then open
and edit it ? ( to min memory usage)
ByteArrayOutputStream zipBaos = new ByteArrayOutputStream();
ZipOutputStream zipOut = new ZipOutputStream(zipBaos);
byte[] tmpBuf = new byte[1024];
while end of files{
byte[] fileContents = getFileContent(); // it is OK
zipOut.putNextEntry(new ZipEntry(fileNameStr));
ByteArrayInputStream in = new ByteArrayInputStream(fileContents);
int len;
while ((len = in.read(tmpBuf)) > 0) {
out.write(tmpBuf, 0, len);
}
zipOut.closeEntry();
}
zipOut.close();