/** * Sets the memory capacity to a desired number of bytes. * If the memory capacity is smaller than the amount of * memory currently used by the cache, tiles are flushed * until the <code>TileCache</code>'s memory usage is less than * <code>memoryCapacity</code>. * * @param memoryCapacity The new capacity, in bytes. */ public synchronized void setMemoryCapacity(long memoryCapacity) { long oldCapacity = this.memoryCapacity; this.memoryCapacity = memoryCapacity; if (this.memoryCapacity < oldCapacity) { memoryControl(); } }
/** * Sets the <code>memoryThreshold</code> value to a floating * point number that ranges from 0.0 to 1.0. * When the cache memory is full, the memory * usage will be reduced to this fraction of * the total cache memory capacity. For example, * a value of .75 will cause 25% of the memory * to be cleared, while retaining 75%. * * @param memoryThreshold Retained fraction of memory * @throws IllegalArgumentException if the memoryThreshold * is less than 0.0 or greater than 1.0 * @since JAI 1.1 */ public synchronized void setMemoryThreshold(float memoryThreshold) { float oldThreshold = this.memoryThreshold; this.memoryThreshold = memoryThreshold; if (this.memoryThreshold < oldThreshold) { memoryControl(); } }
cachedTile = new CachedTileImpl(tileId, tile, tileCacheMetric); if (memoryInUse + cachedTile.tileSize > memoryThreshold) { memoryControl();