Attempt to fix memory leaks with the ChannelInjector

Addresses https://github.com/aadnk/ProtocolLib/issues/70
This commit is contained in:
Dan Mulloy 2014-11-15 14:56:57 -05:00
parent 592874fd5e
commit ca2bc3ecc5

View File

@ -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. * A flag set by the main thread to indiciate that a packet should not be processed.
*/ */
private final ThreadLocal<Boolean> scheduleProcessPackets = new ThreadLocal<Boolean>() { private final ThreadLocal<Boolean> scheduleProcessPackets = new ThreadLocal<Boolean>() {
@Override
protected Boolean initialValue() { protected Boolean initialValue() {
return true; return true;
}; };
@ -667,6 +668,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
* Set the player instance. * Set the player instance.
* @param player - current instance. * @param player - current instance.
*/ */
@Override
public void setPlayer(Player player) { public void setPlayer(Player player) {
this.player = player; this.player = player;
} }
@ -675,6 +677,7 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
* Set the updated player instance. * Set the updated player instance.
* @param updated - updated instance. * @param updated - updated instance.
*/ */
@Override
public void setUpdatedPlayer(Player updated) { public void setUpdatedPlayer(Player updated) {
this.updated = updated; this.updated = updated;
} }
@ -734,6 +737,10 @@ class ChannelInjector extends ByteToMessageDecoder implements Injector {
// Clear cache // Clear cache
factory.invalidate(player); factory.invalidate(player);
} }
// dmulloy2 - attempt to fix memory leakage
this.player = null;
this.updated = null;
} }
} }