ProtocolLib

3M Downloads

Potential memory leak

Ingrim4 opened this issue ยท 0 comments

commented

Describe the bug
A PacketEvent's NetworkMarker is stored in a WeakHashMap<Packet, NetworkMarker>. A NetworkMarker has a list of PostPacketListener.

If a PostPacketListener holds a reference to the Packet it is attached to then the GC is unable to collect the Packet since it is strongly referenced by the PostPacketListener which is referenced by the NetworkMarker which is referenced by the WeakHashMap<Packet, NetworkMarker>. This behavior has only been observed when using async listeners.

To Reproduce
Steps to reproduce the behavior:

  1. clone https://github.com/Ingrim4/protocollib-leak
  2. mvn clean package
  3. put plugin on server
  4. join server
  5. see memory slowly creeping up

Expected behavior
Remove NetworkManager from Map after PostPacketListener execution if possible otherwise add warning to documentation.

Screenshots

jProfiler Memory (Duration: 6min)

grafik

Version Info
https://pastebin.com/RjUHncLZ