Configured our LRU image cache to flush images when we reach a certain
number of bytes used rather than a certain image count. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2173 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ImageManager.java,v 1.43 2003/01/15 02:50:36 mdb Exp $
|
// $Id: ImageManager.java,v 1.44 2003/01/17 02:29:32 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.media.image;
|
package com.threerings.media.image;
|
||||||
|
|
||||||
@@ -95,8 +95,12 @@ public class ImageManager
|
|||||||
|
|
||||||
// create our image cache
|
// create our image cache
|
||||||
int icsize = _cacheSize.getValue();
|
int icsize = _cacheSize.getValue();
|
||||||
Log.debug("Creating image cache [size=" + icsize + "].");
|
Log.debug("Creating image cache [size=" + icsize + "k].");
|
||||||
_ccache = new LRUHashMap(icsize);
|
_ccache = new LRUHashMap(icsize * 1024, new LRUHashMap.ItemSizer() {
|
||||||
|
public int computeSize (Object value) {
|
||||||
|
return (int)((CacheRecord)value).getEstimatedMemoryUsage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// try to figure out which image loader we'll be using
|
// try to figure out which image loader we'll be using
|
||||||
try {
|
try {
|
||||||
@@ -207,6 +211,9 @@ public class ImageManager
|
|||||||
Log.warning("Failed to load image " + key + ".");
|
Log.warning("Failed to load image " + key + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log.info("Loaded " + key.path + ", image=" + image +
|
||||||
|
// ", size=" + ImageUtil.getEstimatedMemoryUsage(image));
|
||||||
|
|
||||||
// create a cache record
|
// create a cache record
|
||||||
crec = new CacheRecord(image);
|
crec = new CacheRecord(image);
|
||||||
_ccache.put(key, crec);
|
_ccache.put(key, crec);
|
||||||
@@ -499,8 +506,9 @@ public class ImageManager
|
|||||||
* framework. */
|
* framework. */
|
||||||
protected static RuntimeAdjust.IntAdjust _cacheSize =
|
protected static RuntimeAdjust.IntAdjust _cacheSize =
|
||||||
new RuntimeAdjust.IntAdjust(
|
new RuntimeAdjust.IntAdjust(
|
||||||
"Size (in images) of the image manager LRU cache [requires reboot]",
|
"Size (in kb of memory used) of the image manager LRU cache " +
|
||||||
"narya.media.image.cache_size", MediaPrefs.config, 100);
|
"[requires restart]", "narya.media.image.cache_size",
|
||||||
|
MediaPrefs.config, 2*1024);
|
||||||
|
|
||||||
/** 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 =
|
protected static RuntimeAdjust.BooleanAdjust _prepareImages =
|
||||||
|
|||||||
Reference in New Issue
Block a user