<div dir="ltr"><div>Hi all,</div><div><br></div><div>I'd like a quick sanity check on a possible memory inefficiency in PNGImageWriter.</div><div><br></div><div>Some of the other image writers, like JPEGImageWriter, do their best to avoid duplicating the image raster + data buffer [1]... although it doesn't look like this was always the case [2].</div><div><br></div><div>The PNGImageWriter, on the other hand, always makes a new raster + data buffer copy for each row [3]. It *is* per-row, so the data isn't all duplicated in one go, but even on a row-by-row basis, it ends up being quite a bit of unnecessary allocation and subsequent garbage collection.</div><div><br></div><div>Can somebody confirm if I'm reading things right, and whether PNGImageWriter would benefit from a similar BufferedImage + single tile check, such as already exists in JPEGImageWriter?</div><div><br></div><div>Thanks!</div><div><br></div><div>Daniel<br></div><div><br></div><div>[1] <a href="https://github.com/openjdk/jdk/blob/e4c7850c177899a5da6f5050cb0647a6e1a75d31/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java#L415">https://github.com/openjdk/jdk/blob/e4c7850c177899a5da6f5050cb0647a6e1a75d31/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java#L415</a></div><div>[2] <a href="https://bugs.openjdk.org/browse/JDK-6266748">https://bugs.openjdk.org/browse/JDK-6266748</a></div><div>[3] <a href="https://github.com/openjdk/jdk/blob/e4c7850c177899a5da6f5050cb0647a6e1a75d31/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java#L923">https://github.com/openjdk/jdk/blob/e4c7850c177899a5da6f5050cb0647a6e1a75d31/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java#L923</a></div><div><br></div></div>