ByteBuf not freed properly in `ServerGamePacketListenerImplMixin`
magneticflux- opened this issue ยท 2 comments
[04:34:47] [Raknetify Epoll #5/ERROR]: LEAK: ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records:
Created at:
io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:403)
io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:188)
io.netty.buffer.UnsafeByteBufUtil.copy(UnsafeByteBufUtil.java:436)
io.netty.buffer.PooledUnsafeDirectByteBuf.copy(PooledUnsafeDirectByteBuf.java:216)
io.netty.buffer.AbstractByteBuf.copy(AbstractByteBuf.java:1194)
net.minecraft.class_2540.copy(class_2540.java:1517)
net.minecraft.class_3244.handler$cfm000$onCustomCarpetPayload(class_3244.java:5534)
net.minecraft.class_3244.method_12075(class_3244.java)
net.minecraft.class_2817.method_12199(class_2817.java:38)
net.minecraft.class_2817.method_11054(class_2817.java:7)
net.minecraft.class_2600.method_11072(class_2600.java:22)
net.minecraft.class_3738.run(class_3738.java:18)
net.minecraft.class_1255.redirect$zgg000$redirectExecuteTask(class_1255.java:521)
net.minecraft.class_1255.method_16075(class_1255.java:131)
net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:14277)
net.minecraft.server.MinecraftServer.method_16075(MinecraftServer.java:752)
net.minecraft.class_1255.method_5383(class_1255.java:116)
net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:736)
net.minecraft.server.MinecraftServer.handler$cgo000$modifiedRunLoop(MinecraftServer.java:9394)
net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:644)
net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:257)
java.base/java.lang.Thread.run(Unknown Source)
Should be an easy fix, just clean up this byte buffer after the method returns:
So the code that does that copy is a bit old and we were thinking if it is really needed, do you know if just removing the copy would fix it? The stacktrace seems to be pointing to the copy call.
I think so, copy()
creates a new buffer which needs to be released manually. Vanilla doesn't bother copying packet data and the call to ensureRunningOnSameThread
means the code will execute on the server's event loop.