When writing a TIFF using DEFLATE as compression algorithm, a java.util.zip.Deflate instance is created. This instance uses native resources, which are only released when Deflate#end() is called, or when the finalize method is invoked.
In order to avoid relying on GC to clean up the native resources through the finalizer, the TIFFDeflater class should call end() when it is disposed. In order to do this, I had to add a dispose method to the TIFFCompressor class and call it from the TIFFImageWriter.
The TIFFImageWriter already has a dispose method, which will now call the dispose method of the TIFFCompressor. As a result, everybody who is using the TIFFImageWriter class correctly (calling dispose when finished) will benefit from this fix.
Inside the TIFFImageWriter class, there was a bogusWriter created, on which the dispose call was lacking. I added this call as well.
When writing a TIFF using DEFLATE as compression algorithm, a
java.util.zip.Deflate
instance is created. This instance uses native resources, which are only released whenDeflate#end()
is called, or when thefinalize
method is invoked.In order to avoid relying on GC to clean up the native resources through the finalizer, the
TIFFDeflater
class should callend()
when it is disposed. In order to do this, I had to add adispose
method to theTIFFCompressor
class and call it from theTIFFImageWriter
.The
TIFFImageWriter
already has adispose
method, which will now call thedispose
method of theTIFFCompressor
. As a result, everybody who is using theTIFFImageWriter
class correctly (callingdispose
when finished) will benefit from this fix.Inside the
TIFFImageWriter
class, there was abogusWriter
created, on which thedispose
call was lacking. I added this call as well.