From 7f8e789cf3b09c1c24bfb8c654763605d24aea50 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 7 May 2020 01:58:23 -0400 Subject: [PATCH] Use a finalizer for light packet instead of onPacketDone Sadly sharing packets is breaking the ability to do this :( We can prob still do a little better than this but will save that for another commit. --- .../Optimize-NibbleArray-to-use-pooled-buffers.patch | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Spigot-Server-Patches/Optimize-NibbleArray-to-use-pooled-buffers.patch b/Spigot-Server-Patches/Optimize-NibbleArray-to-use-pooled-buffers.patch index 92d8ac873..f90c88f20 100644 --- a/Spigot-Server-Patches/Optimize-NibbleArray-to-use-pooled-buffers.patch +++ b/Spigot-Server-Patches/Optimize-NibbleArray-to-use-pooled-buffers.patch @@ -151,12 +151,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public PacketPlayOutLightUpdate() {} + // Paper start -+ private final java.util.List usedBytes = new java.util.ArrayList<>(); ++ private java.util.List usedBytes = new java.util.ArrayList<>(); + + @Override -+ public void onPacketDone() { -+ usedBytes.forEach(NibbleArray::releaseBytes); -+ usedBytes.clear(); ++ public void finalize() throws Throwable { ++ try { ++ usedBytes.forEach(NibbleArray::releaseBytes); ++ usedBytes.clear(); ++ } finally { ++ super.finalize(); ++ } + } + // Paper end