From 5b6bff9d97e0e09ea2f754fedf7b03ac07b8c500 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Tue, 23 May 2006 13:49:47 +0000 Subject: [PATCH] Only count 1000 entities git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2953 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/repo/cache/EhCacheTracerJob.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java b/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java index 173e8275df..151d1dd53d 100644 --- a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java +++ b/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java @@ -159,11 +159,22 @@ public class EhCacheTracerJob implements Job { // calculate the cache deep size - EHCache 1.1 is always returning 0L List keys = cache.getKeys(); + // only count a maximum of 1000 entities + int count = 0; for (Serializable key : keys) { Element element = cache.get(key); size += getSize(element); + count++; + if (count >= 1000) + { + break; + } } + + // the size must be multiplied by the ratio of the count to actual size + size = count > 0L ? (long) (size * ((double)keys.size()/(double)count)) : 0L; + sizeMB = (double)size/1024.0/1024.0; maxSize = cache.getMaxElementsInMemory(); currentSize = cache.getMemoryStoreSize();