A-ha, found the further source of the walk-on-water bug, which is that if
you had logged on to one ocean and then moved to another, the previous ocean's sceneIds are still in the scene cache. Fix: Clear the scene cache both when we log off and when the scene repo is set. Also, I made the cache be a LRUHashMap holding a measly 5 scenes. Why are we filling up memory on the client with scenes that may or may not ever be revisited? git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3385 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -23,7 +23,7 @@ package com.threerings.whirled.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.samskivert.util.HashIntMap;
|
||||
import com.samskivert.util.LRUHashMap;
|
||||
import com.samskivert.util.ResultListener;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
@@ -100,6 +100,7 @@ public class SceneDirector extends BasicDirector
|
||||
public void setSceneRepository (SceneRepository screp)
|
||||
{
|
||||
_screp = screp;
|
||||
_scache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,7 +329,7 @@ public class SceneDirector extends BasicDirector
|
||||
}
|
||||
|
||||
// update our scene cache
|
||||
_scache.put(model.sceneId, model);
|
||||
_scache.put(new Integer(model.sceneId), model);
|
||||
|
||||
// and pass through to the normal move succeeded handler
|
||||
moveSucceeded(placeId, config);
|
||||
@@ -413,13 +414,14 @@ public class SceneDirector extends BasicDirector
|
||||
protected SceneModel loadSceneModel (int sceneId)
|
||||
{
|
||||
// first look in the model cache
|
||||
SceneModel model = (SceneModel)_scache.get(sceneId);
|
||||
Integer key = new Integer(sceneId);
|
||||
SceneModel model = (SceneModel)_scache.get(key);
|
||||
|
||||
// load from the repository if it's not cached
|
||||
if (model == null) {
|
||||
try {
|
||||
model = _screp.loadSceneModel(sceneId);
|
||||
_scache.put(sceneId, model);
|
||||
_scache.put(key, model);
|
||||
|
||||
} catch (NoSuchSceneException nsse) {
|
||||
// nothing special here, just fall through and return null
|
||||
@@ -454,6 +456,7 @@ public class SceneDirector extends BasicDirector
|
||||
|
||||
// clear out our business
|
||||
clearScene();
|
||||
_scache.clear();
|
||||
_pendingSceneId = -1;
|
||||
releaseSceneModel(_pendingModel);
|
||||
_previousSceneId = -1;
|
||||
@@ -483,7 +486,7 @@ public class SceneDirector extends BasicDirector
|
||||
protected SceneFactory _fact;
|
||||
|
||||
/** A cache of scene model information. */
|
||||
protected HashIntMap _scache = new HashIntMap();
|
||||
protected LRUHashMap _scache = new LRUHashMap(5);
|
||||
|
||||
/** The display scene object for the scene we currently occupy. */
|
||||
protected Scene _scene;
|
||||
|
||||
Reference in New Issue
Block a user