Hi João,

> Date: Fri, 28 Sep 2012 02:13:50 -0700
> From: [email protected]
> To: [email protected]
> Subject: Re: [Geotools-gt2-users] GeoTiffReader: unable to dispose,   file 
> still locked
> 
> Hi GT-developers, 
> 
> Even this piece of code locks the GeoTIFF file (as soon as the coverage is
> created by some InputStreams): 
> 
> File geotiff = ...
> BufferedImage bufferedImage = ImageIO.read(geotiff); 
> PlanarImage planarImage = PlanarImage.wrapRenderedImage(bufferedImage); 
> GeoTiffReader reader = new GeoTiffReader(null); 
> cov = reader.createCoverage(planarImage, null); 
> cov.dispose(true);

Have you tried to dispose the planarimage also?
// dispose
org.geotools.resources.image.ImageUtilities.disposePlanarImageChain(planarImage);

Also try to flush the jai cache before dispose the images.
Regards,
Carlo

> In my case (just for reading the BoundingBox of a GeoTIFF file) following
> code did not lock the underlying GeoTIFF file when reading from it, so this
> solves my problem in the meantime: 
> 
> AbstractGridFormat format = GridFormatFinder.findFormat(geotiff); 
> AbstractGridCoverage2DReader gridReader = format.getReader(geotiff); 
> Rectangle2D rect = gridReader.getOriginalEnvelope().toRectangle2D(); 
> 
> // doing something ... (like reading envelope etc.) 
> System.out.println("left: " + Double.toString(rect.getMinX())); 
> System.out.println("bottom: " + Double.toString(rect.getMinY())); 
> System.out.println("right: " + Double.toString(rect.getMaxX())); 
> System.out.println("top: " + Double.toString(rect.getMaxY())); 
> 
> 
> I would nevertheless appreciate if someone can give me a hint how to dispose
> a coverage. 
> Thanks 
> 
> João
> 
> 
> 
> --
> View this message in context: 
> http://osgeo-org.1560.n6.nabble.com/GeoTiffReader-unable-to-dispose-file-still-locked-tp5004582p5005157.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
> 
> ------------------------------------------------------------------------------
> Got visibility?
> Most devs has no idea what their production app looks like.
> Find out how fast your code is with AppDynamics Lite.
> http://ad.doubleclick.net/clk;262219671;13503038;y?
> http://info.appdynamics.com/FreeJavaPerformanceDownload.html
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
                                          
------------------------------------------------------------------------------
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to