8065769: OOM on Window/Solaris in test compile-octane-splitter.js
Reviewed-by: sundar, jlaskey
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AstSerializer.java Wed Dec 03 11:43:57 2014 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/AstSerializer.java Wed Dec 03 14:49:36 2014 +0100
@@ -48,11 +48,13 @@
private static final int COMPRESSION_LEVEL = Options.getIntProperty("nashorn.serialize.compression", 4);
static byte[] serialize(final FunctionNode fn) {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
- try (final ObjectOutputStream oout = new ObjectOutputStream(new DeflaterOutputStream(out,
- new Deflater(COMPRESSION_LEVEL)))) {
+ final Deflater deflater = new Deflater(COMPRESSION_LEVEL);
+ try (final ObjectOutputStream oout = new ObjectOutputStream(new DeflaterOutputStream(out, deflater))) {
oout.writeObject(removeInnerFunctionBodies(fn));
} catch (final IOException e) {
throw new AssertionError("Unexpected exception serializing function", e);
+ } finally {
+ deflater.end();
}
return out.toByteArray();
}