Potential memory leak
Ingrim4 opened this issue ยท 0 comments
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:
- clone https://github.com/Ingrim4/protocollib-leak
- mvn clean package
- put plugin on server
- join server
- see memory slowly creeping up
Expected behavior
Remove NetworkManager
from Map after PostPacketListener
execution if possible otherwise add warning to documentation.
Screenshots
Version Info
https://pastebin.com/RjUHncLZ