From 380762962bda5ccf7ba708bf0a9f976f15df6c06 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 17 Jan 2003 02:28:32 +0000 Subject: [PATCH] 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 --- .../com/threerings/cast/CharacterManager.java | 16 ++++++++++------ .../threerings/cast/CompositedActionFrames.java | 5 ++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/java/com/threerings/cast/CharacterManager.java b/src/java/com/threerings/cast/CharacterManager.java index 8f9bc2196..723df9f42 100644 --- a/src/java/com/threerings/cast/CharacterManager.java +++ b/src/java/com/threerings/cast/CharacterManager.java @@ -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); } diff --git a/src/java/com/threerings/cast/CompositedActionFrames.java b/src/java/com/threerings/cast/CompositedActionFrames.java index ba0e33133..895ac6829 100644 --- a/src/java/com/threerings/cast/CompositedActionFrames.java +++ b/src/java/com/threerings/cast/CompositedActionFrames.java @@ -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;