From bd4927d174e66baf6d23fec8073b5d565b144d69 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 16 Sep 2018 03:21:52 -0400 Subject: [PATCH] more improvements to expiring map stuff --- .../Fix-major-memory-leaks-in-ExpiringMap.patch | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Spigot-Server-Patches/Fix-major-memory-leaks-in-ExpiringMap.patch b/Spigot-Server-Patches/Fix-major-memory-leaks-in-ExpiringMap.patch index db46d64de3..bd67ba1d1f 100644 --- a/Spigot-Server-Patches/Fix-major-memory-leaks-in-ExpiringMap.patch +++ b/Spigot-Server-Patches/Fix-major-memory-leaks-in-ExpiringMap.patch @@ -11,7 +11,7 @@ not run on every manipulation, and instead to run clean once per tick per expiring map. diff --git a/src/main/java/net/minecraft/server/ExpiringMap.java b/src/main/java/net/minecraft/server/ExpiringMap.java -index 4006f5a69c..08d41e8cf0 100644 +index 4006f5a69c..d64c143017 100644 --- a/src/main/java/net/minecraft/server/ExpiringMap.java +++ b/src/main/java/net/minecraft/server/ExpiringMap.java @@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -150,7 +150,7 @@ index 4006f5a69c..08d41e8cf0 100644 - + int ttlSize = this.ttl.size(); + int thisSize = this.size(); -+ if (ttlSize != thisSize) { ++ if (ttlSize < thisSize) { + if (!hasLeaked) { // log once + hasLeaked = true; + MinecraftServer.LOGGER.warn("WARNING: ExpiringMap desync (" + ttlSize + ":" + thisSize + ")- Memory leak risk! We will recover from this, but this means there is still a bug. Please do not open an issue about this. Mention it in Discord (we don't need everyone reporting the same thing)"); @@ -170,6 +170,15 @@ index 4006f5a69c..08d41e8cf0 100644 } protected boolean a(T var1) { +@@ -0,0 +0,0 @@ public class ExpiringMap extends Long2ObjectOpenHashMap { + } + + public T get(long i) { +- this.a(i); ++ if (ttl.containsKey(i)) this.setAccess(i); // Paper + return (T)super.get(i); + } + diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 80e8b023cf..70a609efcc 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java