Revision: 6633
http://sourceforge.net/p/jump-pilot/code/6633
Author: michaudm
Date: 2020-11-22 10:12:19 +0000 (Sun, 22 Nov 2020)
Log Message:
-----------
Find a way to free TiffUtilsV2 cache when necessary (and to avoid useless fiel
lock).
Modified Paths:
--------------
core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java
core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
Modified: core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java
2020-11-22 10:08:22 UTC (rev 6632)
+++ core/trunk/src/org/openjump/core/rasterimage/RasterImageLayer.java
2020-11-22 10:12:19 UTC (rev 6633)
@@ -17,6 +17,7 @@
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import java.awt.image.renderable.ParameterBlock;
+import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.UUID;
@@ -23,6 +24,7 @@
import javax.media.jai.JAI;
+import com.vividsolutions.jump.workbench.model.Disposable;
import org.openjump.core.ccordsys.utils.SRSInfo;
import org.openjump.util.metaData.MetaDataMap;
import org.openjump.util.metaData.ObjectContainingMetaInformation;
@@ -56,7 +58,8 @@
* @version $Rev: 2509 $
* modified: [sstein]: 16.Feb.2009 changed logger-entries to comments, used
frame.warnUser
*/
-public final class RasterImageLayer extends AbstractLayerable implements
ObjectContainingMetaInformation {
+public final class RasterImageLayer extends AbstractLayerable
+ implements ObjectContainingMetaInformation, Disposable {
protected static Blackboard blackboard = null;
@@ -1410,7 +1413,9 @@
public void dispose() {
// TODO: probably a good idea to remove resources when the layer is
closed up
- // dunno what is needed to clean up Sextante though, hence leave it
for now
+ // TiffUtilsV2 contains a cache to avoid reading image files again and
again
+ // but which can hold file lock for ever if entries are not removed.
+ TiffUtilsV2.removeFromGeoRastercache(new File(imageFileName));
}
public Double getCellValue(Coordinate coordinate, int band) throws
IOException {
Modified: core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
===================================================================
--- core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
2020-11-22 10:08:22 UTC (rev 6632)
+++ core/trunk/src/org/openjump/core/rasterimage/TiffUtilsV2.java
2020-11-22 10:12:19 UTC (rev 6633)
@@ -40,8 +40,11 @@
public class TiffUtilsV2 {
// a File -> RenderedOp cache mapping to prevent recreating inputs for the
same file
- private static WeakHashMap<File,GeoReferencedRaster> geoRasterCache = new
WeakHashMap<File,GeoReferencedRaster>();
+ private static WeakHashMap<File,GeoReferencedRaster> geoRasterCache = new
WeakHashMap<>();
+ public static void removeFromGeoRastercache(File file) {
+ geoRasterCache.remove(file);
+ }
public static RenderedOp getRenderedOp(File tiffFile) throws IOException {
GeoReferencedRaster geoRaster = getGeoReferencedRaster(tiffFile);
_______________________________________________
Jump-pilot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel