PacketEvents is emerging as a strong contender in the realm of Minecraft packet processing libraries. Designed to simplify packet manipulation while delivering high performance, this powerful tool aims to demystify the complexities of projects utilizing packets.
GNU General Public License v3.0
513
stars
148
forks
source link
Serverbound memory leak when using with ViaVersion #416
I've noticed a creeping memory leak for the past few months, and this is a bunch of heap dumps to try to figure out where it is coming from. Grim is much too large to establish a leak with packetevents, so I've decided to modify packetevents itself for these tests. A 1.18.2 client and a 1.18.2 server are used to remain consistent:
The byte[] in the packets are the bytebuffers. To measure the size of the bytebuffers, I've enabled -Dio.netty.noPreferDirect=true so that netty uses heap based buffers instead of bytebuffers. You can see that it is leaking with the PING packet with via.
I then tested a packet that also wouldn't do much, that I could spam. I then spammed 20k move vehicle packets a second when the player wasn't in a vehicle, meaning the packet did nothing.
You can see that it doesn't leak with the ping packet. This is how I've established there is no leak with serverbound packets.
My next theory was that it was something to do with the PING packet. So I loaded a debug client that doesn't respond to the PING packet, meaning there is only significant clientbound packets:
So I've established that it is the PONG packet causing the issues The final heap summary will distance myself from this packet to establish that there is a general issue. I've decided to spam 20k serverbound close container packets a second.
I've noticed a creeping memory leak for the past few months, and this is a bunch of heap dumps to try to figure out where it is coming from. Grim is much too large to establish a leak with packetevents, so I've decided to modify packetevents itself for these tests. A 1.18.2 client and a 1.18.2 server are used to remain consistent:
My journey started with the PING packet, so I sent 20k ping packets a second clientbound: Without via: https://spark.lucko.me/9EvzGzsZPL With via: https://spark.lucko.me/G0ONj0bBgE
The byte[] in the packets are the bytebuffers. To measure the size of the bytebuffers, I've enabled -Dio.netty.noPreferDirect=true so that netty uses heap based buffers instead of bytebuffers. You can see that it is leaking with the PING packet with via.
I then tested a packet that also wouldn't do much, that I could spam. I then spammed 20k move vehicle packets a second when the player wasn't in a vehicle, meaning the packet did nothing.
With via: https://spark.lucko.me/EgLiBHrHeL
You can see that it doesn't leak with the ping packet. This is how I've established there is no leak with serverbound packets.
My next theory was that it was something to do with the PING packet. So I loaded a debug client that doesn't respond to the PING packet, meaning there is only significant clientbound packets:
With via: https://spark.lucko.me/xcfLyiNRqt
So I've established that it is the PONG packet causing the issues The final heap summary will distance myself from this packet to establish that there is a general issue. I've decided to spam 20k serverbound close container packets a second.
With via: https://spark.lucko.me/1vbi5MzhvB
You can see that serverbound packets are leaking with viaversion. I don't have the debug listener enabled. Something is wrong.