diff --git a/src/main/java/stormpot/BAllocThread.java b/src/main/java/stormpot/BAllocThread.java index 12b51adc..ec128898 100644 --- a/src/main/java/stormpot/BAllocThread.java +++ b/src/main/java/stormpot/BAllocThread.java @@ -396,12 +396,14 @@ int allocatedSize() { } int inUse() { - int inUse = size - live.size(); // slots not in live are in thread locals? + int inUse = 0; + int liveSize = 0; for (BSlot slot: live) { + liveSize++; if (slot.isClaimedOrThreadLocal()) { inUse++; } } - return inUse; - } + return size - liveSize + inUse; + } } diff --git a/src/main/java/stormpot/DirectAllocationController.java b/src/main/java/stormpot/DirectAllocationController.java index 603732e1..de731118 100644 --- a/src/main/java/stormpot/DirectAllocationController.java +++ b/src/main/java/stormpot/DirectAllocationController.java @@ -123,12 +123,14 @@ public int allocatedSize() { } int inUse() { - int inUse = size - live.size(); + int inUse = 0; + int liveSize = 0; for (BSlot slot: live) { + liveSize++; if (slot.isClaimedOrThreadLocal()) { inUse++; } } - return inUse; + return size - liveSize + inUse; } } diff --git a/src/main/java/stormpot/InlineAllocationController.java b/src/main/java/stormpot/InlineAllocationController.java index adbacfe7..55f5010a 100644 --- a/src/main/java/stormpot/InlineAllocationController.java +++ b/src/main/java/stormpot/InlineAllocationController.java @@ -369,12 +369,14 @@ public int allocatedSize() { } int inUse() { - int inUse = size - live.size(); + int inUse = 0; + int liveSize = 0; for (BSlot slot: live) { + liveSize++; if (slot.isClaimedOrThreadLocal()) { inUse++; } } - return inUse; - } + return size - liveSize + inUse; + } }