Release some memory sooner during ingest
@@ -507,10 +507,9 @@ object IngestImage extends MrGeoDriver with Externalizable {
// open the image
try {
- val src = GDALUtils.open(image)
+ var src = GDALUtils.open(image)
if (src != null) {
- try {
val datatype = src.GetRasterBand(1).getDataType
val datasize = gdal.GetDataTypeSize(datatype) / 8
@@ -601,7 +600,14 @@ object IngestImage extends MrGeoDriver with Externalizable {
gdalconstConstants.GRA_Bilinear
}
+ try {
gdal.ReprojectImage(src, scaled, src.GetProjection(), GDALUtils.EPSG4326, resample)
+ }
+ finally {
+ // close the image
+ GDALUtils.close(src)
+ src = null;
+ }
// val time = System.currentTimeMillis() - start
// println("scale: " + time)
@@ -645,12 +651,6 @@ object IngestImage extends MrGeoDriver with Externalizable {
finally {
GDALUtils.delete(scaled)
}
-
- }
- finally {
- // close the image
- GDALUtils.close(src)
- }
}
else {
//if (log.isDebugEnabled) {
