Use runtime adjustments for our image and tile cache size.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2145 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ImageManager.java,v 1.37 2003/01/14 04:05:56 mdb Exp $
|
// $Id: ImageManager.java,v 1.38 2003/01/15 00:47:08 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.image;
|
package com.threerings.media.image;
|
||||||
|
|
||||||
@@ -27,13 +27,14 @@ import javax.imageio.ImageIO;
|
|||||||
import javax.imageio.stream.ImageInputStream;
|
import javax.imageio.stream.ImageInputStream;
|
||||||
|
|
||||||
import com.samskivert.io.NestableIOException;
|
import com.samskivert.io.NestableIOException;
|
||||||
import com.samskivert.util.ConfigUtil;
|
|
||||||
import com.samskivert.util.LRUHashMap;
|
import com.samskivert.util.LRUHashMap;
|
||||||
|
import com.samskivert.util.RuntimeAdjust;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.samskivert.util.Throttle;
|
import com.samskivert.util.Throttle;
|
||||||
import com.samskivert.util.Tuple;
|
import com.samskivert.util.Tuple;
|
||||||
|
|
||||||
import com.threerings.media.Log;
|
import com.threerings.media.Log;
|
||||||
|
import com.threerings.media.MediaPrefs;
|
||||||
import com.threerings.resource.ResourceManager;
|
import com.threerings.resource.ResourceManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,8 +94,8 @@ public class ImageManager
|
|||||||
_rmgr = rmgr;
|
_rmgr = rmgr;
|
||||||
|
|
||||||
// create our image cache
|
// create our image cache
|
||||||
int icsize = ConfigUtil.getSystemProperty(
|
int icsize = MediaPrefs.config.getValue(
|
||||||
"narya.media.image.cache_size", DEFAULT_IMAGE_CACHE_SIZE);
|
IMAGE_CACHE_SIZE_KEY, DEFAULT_IMAGE_CACHE_SIZE);
|
||||||
Log.debug("Creating image cache [size=" + icsize + "].");
|
Log.debug("Creating image cache [size=" + icsize + "].");
|
||||||
_ccache = new LRUHashMap(icsize);
|
_ccache = new LRUHashMap(icsize);
|
||||||
|
|
||||||
@@ -491,6 +492,17 @@ public class ImageManager
|
|||||||
protected static final String IMAGEIO_LOADER =
|
protected static final String IMAGEIO_LOADER =
|
||||||
"com.threerings.media.image.ImageIOLoader";
|
"com.threerings.media.image.ImageIOLoader";
|
||||||
|
|
||||||
|
/** The config key for our cache size property. */
|
||||||
|
protected static final String IMAGE_CACHE_SIZE_KEY =
|
||||||
|
"narya.media.image.cache_size";
|
||||||
|
|
||||||
/** The maximum number of images that may be cached at any one time. */
|
/** The maximum number of images that may be cached at any one time. */
|
||||||
protected static final int DEFAULT_IMAGE_CACHE_SIZE = 100;
|
protected static final int DEFAULT_IMAGE_CACHE_SIZE = 100;
|
||||||
|
|
||||||
|
/** Register our image cache size with the runtime adjustments
|
||||||
|
* framework. */
|
||||||
|
protected static RuntimeAdjust.IntAdjust _cacheSize =
|
||||||
|
new RuntimeAdjust.IntAdjust(
|
||||||
|
"Size (in images) of the image manager LRU cache [requires reboot]",
|
||||||
|
IMAGE_CACHE_SIZE_KEY, MediaPrefs.config, DEFAULT_IMAGE_CACHE_SIZE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TileSet.java,v 1.36 2003/01/13 22:49:46 mdb Exp $
|
// $Id: TileSet.java,v 1.37 2003/01/15 00:47:09 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile;
|
package com.threerings.media.tile;
|
||||||
|
|
||||||
@@ -8,12 +8,13 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import com.samskivert.util.ConfigUtil;
|
|
||||||
import com.samskivert.util.LRUHashMap;
|
import com.samskivert.util.LRUHashMap;
|
||||||
|
import com.samskivert.util.RuntimeAdjust;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
import com.samskivert.util.Tuple;
|
import com.samskivert.util.Tuple;
|
||||||
|
|
||||||
import com.threerings.media.Log;
|
import com.threerings.media.Log;
|
||||||
|
import com.threerings.media.MediaPrefs;
|
||||||
import com.threerings.media.image.Colorization;
|
import com.threerings.media.image.Colorization;
|
||||||
import com.threerings.media.image.Mirage;
|
import com.threerings.media.image.Mirage;
|
||||||
|
|
||||||
@@ -140,8 +141,8 @@ public abstract class TileSet
|
|||||||
|
|
||||||
// create our tile cache if necessary
|
// create our tile cache if necessary
|
||||||
if (_tiles == null) {
|
if (_tiles == null) {
|
||||||
int tcsize = ConfigUtil.getSystemProperty(
|
int tcsize = MediaPrefs.config.getValue(
|
||||||
"narya.media.tile.cache_size", DEFAULT_TILE_CACHE_SIZE);
|
TILE_CACHE_SIZE_KEY, DEFAULT_TILE_CACHE_SIZE);
|
||||||
Log.debug("Creating tile cache [size=" + tcsize + "].");
|
Log.debug("Creating tile cache [size=" + tcsize + "].");
|
||||||
_tiles = new LRUHashMap(tcsize);
|
_tiles = new LRUHashMap(tcsize);
|
||||||
}
|
}
|
||||||
@@ -301,6 +302,17 @@ public abstract class TileSet
|
|||||||
/** A weak cache of our tiles. */
|
/** A weak cache of our tiles. */
|
||||||
protected static LRUHashMap _tiles;
|
protected static LRUHashMap _tiles;
|
||||||
|
|
||||||
|
/** The config key for our cache size property. */
|
||||||
|
protected static final String TILE_CACHE_SIZE_KEY =
|
||||||
|
"narya.media.tile.cache_size";
|
||||||
|
|
||||||
/** The default tile cache size. */
|
/** The default tile cache size. */
|
||||||
protected static final int DEFAULT_TILE_CACHE_SIZE = 500;
|
protected static final int DEFAULT_TILE_CACHE_SIZE = 500;
|
||||||
|
|
||||||
|
/** Register our tile cache size with the runtime adjustments
|
||||||
|
* framework. */
|
||||||
|
protected static RuntimeAdjust.IntAdjust _cacheSize =
|
||||||
|
new RuntimeAdjust.IntAdjust(
|
||||||
|
"Size (in tiles) of the tile LRU cache [requires reboot]",
|
||||||
|
TILE_CACHE_SIZE_KEY, MediaPrefs.config, DEFAULT_TILE_CACHE_SIZE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user