Only use the set cache value for the current set of managers, don't store it in the RuntimeAdjust

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@535 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Charlie Groves
2008-06-10 21:37:57 +00:00
parent 06e3217d6b
commit d67c0bd7b7
2 changed files with 18 additions and 8 deletions
@@ -33,7 +33,6 @@ import com.samskivert.util.LRUHashMap;
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.image.Colorization; import com.threerings.media.image.Colorization;
import com.threerings.media.image.ImageManager; import com.threerings.media.image.ImageManager;
import com.threerings.util.DirectionCodes; import com.threerings.util.DirectionCodes;
@@ -56,7 +55,7 @@ public class CharacterManager
*/ */
public static void setCacheSize (int cacheKilobytes) 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 // create a cache for our composited action frames
int acsize = _cacheSize.getValue(); log.debug("Creating action cache [size=" + _runCacheSize + "k].");
log.debug("Creating action cache [size=" + acsize + "k]."); _frameCache = new LRUHashMap(_runCacheSize * 1024, new LRUHashMap.ItemSizer() {
_frameCache = new LRUHashMap(acsize*1024, new LRUHashMap.ItemSizer() {
public int computeSize (Object value) { public int computeSize (Object value) {
return (int)((CompositedMultiFrameImage) return (int)((CompositedMultiFrameImage)
value).getEstimatedMemoryUsage(); value).getEstimatedMemoryUsage();
@@ -183,7 +181,7 @@ public class CharacterManager
frames = createCompositeFrames(descrip, action); frames = createCompositeFrames(descrip, action);
_actionFrames.put(key, frames); _actionFrames.put(key, frames);
} }
// periodically report our frame image cache performance // periodically report our frame image cache performance
if (!_cacheStatThrottle.throttleOp()) { if (!_cacheStatThrottle.throttleOp()) {
long size = getEstimatedCacheMemoryUsage(); long size = getEstimatedCacheMemoryUsage();
@@ -459,4 +457,10 @@ public class CharacterManager
"Size (in kb of memory used) of the character manager LRU " + "Size (in kb of memory used) of the character manager LRU " +
"action cache [requires restart]", "narya.cast.action_cache_size", "action cache [requires restart]", "narya.cast.action_cache_size",
CastPrefs.config, 32768); 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();
} }
@@ -41,7 +41,7 @@ public class ClientImageManager extends ImageManager
*/ */
public static void setCacheSize (int cacheKilobytes) public static void setCacheSize (int cacheKilobytes)
{ {
_cacheSize.setValue(cacheKilobytes); _runCacheSize = cacheKilobytes;
} }
public ClientImageManager (ResourceManager rmgr, OptimalImageCreator icreator) public ClientImageManager (ResourceManager rmgr, OptimalImageCreator icreator)
@@ -57,7 +57,7 @@ public class ClientImageManager extends ImageManager
@Override @Override
public int getCacheSize () public int getCacheSize ()
{ {
return _cacheSize.getValue(); return _runCacheSize;
} }
@Override @Override
@@ -95,6 +95,12 @@ public class ClientImageManager extends ImageManager
protected static RuntimeAdjust.IntAdjust _cacheSize = new RuntimeAdjust.IntAdjust( protected static RuntimeAdjust.IntAdjust _cacheSize = new RuntimeAdjust.IntAdjust(
"Size (in kb of memory used) of the image manager LRU cache [requires restart]", "Size (in kb of memory used) of the image manager LRU cache [requires restart]",
"narya.media.image.cache_size", MediaPrefs.config, DEFAULT_CACHE_SIZE); "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. */ /** Controls whether or not we prepare images or use raw versions. */
protected static RuntimeAdjust.BooleanAdjust _prepareImages = new RuntimeAdjust.BooleanAdjust( protected static RuntimeAdjust.BooleanAdjust _prepareImages = new RuntimeAdjust.BooleanAdjust(