Writing many PNGs eventually results in OutOfMemoryErrors and the java runtime
crashing without any messages due to running out of native heap space. The
problem occurs because the native resources associated with the Deflater created
on line 144 of PNGImageWriter are never released.
The problem also occurs in PNGImageReader because the InflaterInputStream
(PNGImageReader.java:595) used to read the compressed data is never closed, and
hence the Inflater it uses does not release the native resources.
Read more about the problem here: