Fix calculation of PoolArena metrics after introducing a regression in 89da788fd2

This commit is contained in:
Norman Maurer 2016-03-17 10:06:37 +01:00
parent 0a87c98993
commit 36f3999632

View File

@ -470,7 +470,7 @@ abstract class PoolArena<T> implements PoolArenaMetric {
public long numDeallocations() { public long numDeallocations() {
final long deallocs; final long deallocs;
synchronized (this) { synchronized (this) {
deallocs = deallocationsTiny + deallocationsSmall + allocationsNormal; deallocs = deallocationsTiny + deallocationsSmall + deallocationsNormal;
} }
return deallocs + deallocationsHuge.value(); return deallocs + deallocationsHuge.value();
} }
@ -502,11 +502,11 @@ abstract class PoolArena<T> implements PoolArenaMetric {
@Override @Override
public long numActiveAllocations() { public long numActiveAllocations() {
long val; long val = allocationsTiny.value() + allocationsSmall.value() + allocationsHuge.value()
- deallocationsHuge.value();
synchronized (this) { synchronized (this) {
val = allocationsNormal - deallocationsTiny - deallocationsSmall - allocationsNormal; val += allocationsNormal - (deallocationsTiny + deallocationsSmall + deallocationsNormal);
} }
val -= deallocationsHuge.value();
return val >= 0 ? val : 0; return val >= 0 ? val : 0;
} }