mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-28 05:35:28 +01:00
Attempt to fix memory leaks with the ChannelInjector
Addresses https://github.com/aadnk/ProtocolLib/issues/70
This commit is contained in:
parent
592874fd5e
commit
ca2bc3ecc5
@ -113,6 +113,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
||||
* A flag set by the main thread to indiciate that a packet should not be processed.
|
||||
*/
|
||||
private final ThreadLocal<Boolean> scheduleProcessPackets = new ThreadLocal<Boolean>() {
|
||||
@Override
|
||||
protected Boolean initialValue() {
|
||||
return true;
|
||||
};
|
||||
@ -667,6 +668,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
||||
* Set the player instance.
|
||||
* @param player - current instance.
|
||||
*/
|
||||
@Override
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
@ -675,6 +677,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
||||
* Set the updated player instance.
|
||||
* @param updated - updated instance.
|
||||
*/
|
||||
@Override
|
||||
public void setUpdatedPlayer(Player updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
@ -734,6 +737,10 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
|
||||
// Clear cache
|
||||
factory.invalidate(player);
|
||||
}
|
||||
|
||||
// dmulloy2 - attempt to fix memory leakage
|
||||
this.player = null;
|
||||
this.updated = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user