int increment = getObjectSizeEstimator().estimateSize(task);
int maxTotalMemorySize = getMaxTotalMemorySize();
int totalCounter = this.totalCounter.addAndGet(increment);
if (task instanceof ChannelEventRunnable) {
Channel channel = ((ChannelEventRunnable) task).getEvent().getChannel();
int maxChannelMemorySize = getMaxChannelMemorySize();
int channelCounter = getChannelCounter(channel).addAndGet(increment);
if (maxChannelMemorySize != 0 && channelCounter >= maxChannelMemorySize && channel.isOpen()) {
if (channel.isReadable()) {
channel.setReadable(false);
}
}
}
return maxTotalMemorySize != 0 && totalCounter >= maxTotalMemorySize;