mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user