diff --git a/src/java/com/threerings/cast/CharacterManager.java b/src/java/com/threerings/cast/CharacterManager.java index 9f2986f1..3c2813fb 100644 --- a/src/java/com/threerings/cast/CharacterManager.java +++ b/src/java/com/threerings/cast/CharacterManager.java @@ -33,7 +33,6 @@ import com.samskivert.util.LRUHashMap; import com.samskivert.util.StringUtil; import com.samskivert.util.Throttle; import com.samskivert.util.Tuple; - import com.threerings.media.image.Colorization; import com.threerings.media.image.ImageManager; import com.threerings.util.DirectionCodes; @@ -56,7 +55,7 @@ public class CharacterManager */ public static void setCacheSize (int cacheKilobytes) { - _cacheSize.setValue(cacheKilobytes); + _runCacheSize = cacheKilobytes; } /** @@ -76,9 +75,8 @@ public class CharacterManager } // create a cache for our composited action frames - int acsize = _cacheSize.getValue(); - log.debug("Creating action cache [size=" + acsize + "k]."); - _frameCache = new LRUHashMap(acsize*1024, new LRUHashMap.ItemSizer() { + log.debug("Creating action cache [size=" + _runCacheSize + "k]."); + _frameCache = new LRUHashMap(_runCacheSize * 1024, new LRUHashMap.ItemSizer() { public int computeSize (Object value) { return (int)((CompositedMultiFrameImage) value).getEstimatedMemoryUsage(); @@ -183,7 +181,7 @@ public class CharacterManager frames = createCompositeFrames(descrip, action); _actionFrames.put(key, frames); } - + // periodically report our frame image cache performance if (!_cacheStatThrottle.throttleOp()) { long size = getEstimatedCacheMemoryUsage(); @@ -459,4 +457,10 @@ public class CharacterManager "Size (in kb of memory used) of the character manager LRU " + "action cache [requires restart]", "narya.cast.action_cache_size", CastPrefs.config, 32768); + + /** + * Cache size to be used in this run. Adjusted by setCacheSize without affecting + * the stored value. + */ + protected static int _runCacheSize = _cacheSize.getValue(); } diff --git a/src/java/com/threerings/media/image/ClientImageManager.java b/src/java/com/threerings/media/image/ClientImageManager.java index 37591d25..ce32d9f6 100644 --- a/src/java/com/threerings/media/image/ClientImageManager.java +++ b/src/java/com/threerings/media/image/ClientImageManager.java @@ -41,7 +41,7 @@ public class ClientImageManager extends ImageManager */ public static void setCacheSize (int cacheKilobytes) { - _cacheSize.setValue(cacheKilobytes); + _runCacheSize = cacheKilobytes; } public ClientImageManager (ResourceManager rmgr, OptimalImageCreator icreator) @@ -57,7 +57,7 @@ public class ClientImageManager extends ImageManager @Override public int getCacheSize () { - return _cacheSize.getValue(); + return _runCacheSize; } @Override @@ -95,6 +95,12 @@ public class ClientImageManager extends ImageManager protected static RuntimeAdjust.IntAdjust _cacheSize = new RuntimeAdjust.IntAdjust( "Size (in kb of memory used) of the image manager LRU cache [requires restart]", "narya.media.image.cache_size", MediaPrefs.config, DEFAULT_CACHE_SIZE); + + /** + * Cache size to be used in this run. Adjusted by setCacheSize without affecting + * the stored value. + */ + protected static int _runCacheSize = _cacheSize.getValue(); /** Controls whether or not we prepare images or use raw versions. */ protected static RuntimeAdjust.BooleanAdjust _prepareImages = new RuntimeAdjust.BooleanAdjust(