Cast manager now caches based on memory usage of the cached action frame

images, except that this is all fucked because the action frames get
generated on the fly which means that we'd need to update the LRU cache
with info on our new size which would hugely complicated things, so
instead we're going to rework the whole business in the future to cache
individually composited images rather than the whole goddamned action
frame kit and kaboodle.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2172 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-01-17 02:28:32 +00:00
parent 2640baf727
commit 380762962b
2 changed files with 12 additions and 9 deletions
@@ -1,5 +1,5 @@
//
// $Id: CharacterManager.java,v 1.31 2003/01/15 02:36:59 mdb Exp $
// $Id: CharacterManager.java,v 1.32 2003/01/17 02:28:32 mdb Exp $
package com.threerings.cast;
@@ -45,8 +45,12 @@ public class CharacterManager
// create our in-memory action cache
int acsize = _cacheSize.getValue();
Log.debug("Creating action cache [size=" + acsize + "].");
_frames = new LRUHashMap(acsize);
Log.debug("Creating action cache [size=" + acsize + "k].");
_frames = new LRUHashMap(acsize*1024, new LRUHashMap.ItemSizer() {
public int computeSize (Object value) {
return (int)((ActionFrames)value).getEstimatedMemoryUsage();
}
});
_frames.setTracking(true); // TODO
}
@@ -281,7 +285,7 @@ public class CharacterManager
* framework. */
protected static RuntimeAdjust.IntAdjust _cacheSize =
new RuntimeAdjust.IntAdjust(
"Size (in actions) of the character manager LRU action " +
"cache [requires reboot]", "narya.cast.action_cache_size",
CastPrefs.config, 30);
"Size (in kb of memory used) of the character manager LRU " +
"action cache [requires restart]", "narya.cast.action_cache_size",
CastPrefs.config, 2*1024);
}
@@ -1,5 +1,5 @@
//
// $Id: CompositedActionFrames.java,v 1.13 2003/01/13 23:53:04 mdb Exp $
// $Id: CompositedActionFrames.java,v 1.14 2003/01/17 02:28:32 mdb Exp $
package com.threerings.cast;
@@ -146,8 +146,7 @@ public class CompositedActionFrames
if (mirage == null) {
continue;
}
// TODO: do the right thing here
size += (mirage.getWidth() * mirage.getHeight() * 4);
size += mirage.getEstimatedMemoryUsage();
}
}
return size;