/// <summary> /// Tries to use the DEM stored in memory. /// </summary> /// <returns>NULL if the in-memory DEM is not available.</returns> private RasterDigitalElevationModelBase TryMemory() { RasterDigitalElevationModelBase result = null; long maxBytes = 1024 * 1024 * 1024 * 2L; // 2 GiB // 2 GiB is the .NET limit for allocating RAM, at least in 2.0. // See https://stackoverflow.com/questions/1087982/single-objects-still-limited-to-2-gb-in-size-in-clr-4-0 if (RequiredBytes > maxBytes) { this.ActivityLogger.LogFormat(ActivityLogLevel.Warning, "In-memory cache not available due to DEM size of {0} MiB bigger than 2 GiB.", RequiredMebibytes); return(null); } try { result = new MemoryBasedRasterDigitalElevationModel( lonResolution, latResolution, lonOffset, latOffset, lonLength, latLength); } catch (OverflowException) { return(null); } catch (OutOfMemoryException) { this.ActivityLogger.LogFormat(ActivityLogLevel.Warning, "In-memory cache not available due to not enough free memory. DEM needs {0} MiB.", RequiredMebibytes); return(null); } return(result); }
public override object Clone() { MemoryBasedRasterDigitalElevationModel clone = new MemoryBasedRasterDigitalElevationModel( LonResolution, LatResolution, LonOffset, LatOffset, LonLength, LatLength); clone.data = (Int16[])this.data.Clone(); return(clone); }