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.
This commit is contained in:
Aikar 2020-05-07 01:58:23 -04:00
parent 9204e8c641
commit 7f8e789cf3

View file

@ -151,12 +151,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public PacketPlayOutLightUpdate() {}
+ // Paper start
+ private final java.util.List<byte[]> usedBytes = new java.util.ArrayList<>();
+ private java.util.List<byte[]> 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