Attempt to fix memory leak with TrackableTypes.

The problem was that TrackableTypes were all global (held in static variables), but kept around state (objLookup maps) that shouldn't be global - e.g. that could contain per game data. Additionally, it seems this state wasn't always getting cleared correctly and thus would cause leaking of memory over multiple games - which would especially be a problem for Simulated AI code which created temporary games for simulation.

This change attempts to fix the issue by moving the storage of objLookup maps to the Tracker object, which corresponds to a single Game. This way, there is no cross-contamination between different games and the state is properly cleaned up when a Game goes away.
This commit is contained in:
Myrd
2016-12-30 19:34:07 +00:00
parent 6f0eda7509
commit 18ba55ae27
4 changed files with 29 additions and 12 deletions

View File

@@ -72,10 +72,6 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
public void setGameView(final GameView gameView0) {
if (gameView == null || gameView0 == null) {
if (gameView0 != null) {
//ensure lookup dictionaries are reset before each game
TrackableTypes.CardViewType.clearLookupDictionary();
TrackableTypes.PlayerViewType.clearLookupDictionary();
TrackableTypes.StackItemViewType.clearLookupDictionary();
gameView0.updateObjLookup();
}
gameView = gameView0;