diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 94efd05f..9b03a33c 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -1076,6 +1076,10 @@ public class MapManager { if(saverestorepending) savePending(); + if(sscache != null) { + sscache.cleanup(); + sscache = null; + } } private HashMap worldTileDirectories = new HashMap(); diff --git a/src/main/java/org/dynmap/utils/SnapshotCache.java b/src/main/java/org/dynmap/utils/SnapshotCache.java index ee321fba..6bd26001 100644 --- a/src/main/java/org/dynmap/utils/SnapshotCache.java +++ b/src/main/java/org/dynmap/utils/SnapshotCache.java @@ -122,8 +122,10 @@ public class SnapshotCache { private void processRefQueue() { Reference ref; while((ref = refqueue.poll()) != null) { - String k = snapcache.reverselookup.get(ref); - if(k != null) snapcache.remove(k); + String k = snapcache.reverselookup.remove(ref); + if(k != null) { + snapcache.remove(k); + } } } /** @@ -141,5 +143,16 @@ public class SnapshotCache { public void resetStats() { cache_attempts = cache_success = 0; } + /** + * Cleanup + */ + public void cleanup() { + if(snapcache != null) { + snapcache.clear(); + snapcache.reverselookup.clear(); + snapcache.reverselookup = null; + snapcache = null; + } + } }