diff --git a/buffer/src/main/java/io/netty/buffer/PoolArena.java b/buffer/src/main/java/io/netty/buffer/PoolArena.java index d6481128a2..88faa1d123 100644 --- a/buffer/src/main/java/io/netty/buffer/PoolArena.java +++ b/buffer/src/main/java/io/netty/buffer/PoolArena.java @@ -468,7 +468,7 @@ abstract class PoolArena implements PoolArenaMetric { public long numDeallocations() { final long deallocs; synchronized (this) { - deallocs = deallocationsTiny + deallocationsSmall + allocationsNormal; + deallocs = deallocationsTiny + deallocationsSmall + deallocationsNormal; } return deallocs + deallocationsHuge.value(); } @@ -500,11 +500,11 @@ abstract class PoolArena implements PoolArenaMetric { @Override public long numActiveAllocations() { - long val; + long val = allocationsTiny.value() + allocationsSmall.value() + allocationsHuge.value() + - deallocationsHuge.value(); synchronized (this) { - val = allocationsNormal - deallocationsTiny - deallocationsSmall - allocationsNormal; + val += allocationsNormal - (deallocationsTiny + deallocationsSmall + deallocationsNormal); } - val -= deallocationsHuge.value(); return val >= 0 ? val : 0; }