mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 19:25:15 +01:00
Fix accumulation of weak reference keys (mem leak) in snapshot cache
This commit is contained in:
parent
bd92cc37bf
commit
babc8cd073
@ -1076,6 +1076,10 @@ public class MapManager {
|
||||
|
||||
if(saverestorepending)
|
||||
savePending();
|
||||
if(sscache != null) {
|
||||
sscache.cleanup();
|
||||
sscache = null;
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<World, File> worldTileDirectories = new HashMap<World, File>();
|
||||
|
@ -122,8 +122,10 @@ public class SnapshotCache {
|
||||
private void processRefQueue() {
|
||||
Reference<? extends ChunkSnapshot> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user