diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java index a1741ba7e..e0bf584ac 100644 --- a/htroot/PerformanceQueues_p.java +++ b/htroot/PerformanceQueues_p.java @@ -289,7 +289,7 @@ public class PerformanceQueues_p { // table cache settings prop.putNum("wordCacheSize", indexSegment.RWIBufferCount()); - prop.putNum("wordCacheSizeKBytes", rwi == null ? 0 : rwi.getBufferSizeBytes()/1024); + prop.putNum("wordCacheSizeKBytes", rwi == null ? 0 : rwi.getBufferSizeBytes() / 1024L); prop.putNum("maxURLinCache", rwi == null ? 0 : rwi.getBufferMaxReferences()); prop.putNum("maxAgeOfCache", rwi == null ? 0 : rwi.getBufferMaxAge() / 1000 / 60); // minutes prop.putNum("minAgeOfCache", rwi == null ? 0 : rwi.getBufferMinAge() / 1000 / 60); // minutes diff --git a/source/net/yacy/cora/util/ByteArray.java b/source/net/yacy/cora/util/ByteArray.java index e117e9670..f54b9e93a 100644 --- a/source/net/yacy/cora/util/ByteArray.java +++ b/source/net/yacy/cora/util/ByteArray.java @@ -44,6 +44,10 @@ public class ByteArray { public ByteArray(final byte[] bb) { this.buffer = bb; } + + public long usedMemory() { + return this.buffer.length; + } public byte[] asBytes() { return this.buffer; diff --git a/source/net/yacy/kelondro/rwi/IndexCell.java b/source/net/yacy/kelondro/rwi/IndexCell.java index f3ea810b2..7365813af 100644 --- a/source/net/yacy/kelondro/rwi/IndexCell.java +++ b/source/net/yacy/kelondro/rwi/IndexCell.java @@ -631,7 +631,7 @@ public final class IndexCell extends AbstractBu @Override public long getBufferSizeBytes() { - return 10000 * this.ram.size(); // guessed; we don't know that exactly because there is no statistics here (expensive, not necessary) + return this.ram.usedMemory(); } @Override diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java index 478a133ce..b3809c1a7 100644 --- a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java +++ b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java @@ -201,6 +201,16 @@ public final class ReferenceContainerCache exte public int size() { return (this.cache == null) ? 0 : this.cache.size(); } + + public long usedMemory() { + if (this.cache == null) return 0; + long b = 0L; + for (Map.Entry> e: this.cache.entrySet()) { + b += e.getKey().usedMemory(); + b += e.getValue().mem(); + } + return b; + } public boolean isEmpty() { if (this.cache == null) return true;