Yatopia/patches/server/0045-Fix-LightEngineThreaded-memory-leak.patch
Ivan Pekov c4a1166224
Add more permanent getLastTick time API
Also fix bad plugins that touch NMS not working
2020-09-27 19:05:16 +03:00

32 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Thu, 10 Sep 2020 21:02:26 +0300
Subject: [PATCH] Fix LightEngineThreaded memory leak
diff --git a/src/main/java/net/minecraft/server/LightEngineThreaded.java b/src/main/java/net/minecraft/server/LightEngineThreaded.java
index fd0beefb900c064d3c35a3d2f79f5b7d9c1287bb..4d024a4849b7566c0faba131caab57b4ddf35e29 100644
--- a/src/main/java/net/minecraft/server/LightEngineThreaded.java
+++ b/src/main/java/net/minecraft/server/LightEngineThreaded.java
@@ -104,6 +104,8 @@ public class LightEngineThreaded extends LightEngine implements AutoCloseable {
}
}
+ public final void remove(long chunkId) { pendingTasks.removeIf(task -> task.chunkId == chunkId); queueUpdate(); } // Yatopia
+
public final boolean isEmpty() {
return this.size == 0 && this.pendingTasks.isEmpty();
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 0d3d1098c570a7b3d5092dd4f25d3a36581706d9..4b86411f5e0dd9319deee3296827080ccb7865a5 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1815,6 +1815,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
// Paper end
+ chunkProvider.getLightEngine().queue.remove(chunk.getPos().pair()); // Yatopia - unregister from light queue
}
public void unregisterEntity(Entity entity) {