Commit 304c2ed5 authored by guus's avatar guus

Updated the calculation of cached size of instances (OF-333)

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11566 b35dd754-fafc-0310-a699-88a17e54d16e
parent 37feb1f8
......@@ -734,11 +734,19 @@ public class Roster implements Cacheable, Externalizable {
public int getCachedSize() {
// Approximate the size of the object in bytes by calculating the size
// of each field.
// of the content of each field, if that content is likely to be eligable for
// garbage collection if the Roster instance is dereferenced.
int size = 0;
size += CacheSizes.sizeOfObject(); // overhead of object
size += CacheSizes.sizeOfCollection(rosterItems.values()); // roster item cache
size += CacheSizes.sizeOfString(username); // username
// implicitFrom
for(Map.Entry<String, Set<String>> entry : implicitFrom.entrySet()) {
size += CacheSizes.sizeOfString(entry.getKey());
size += CacheSizes.sizeOfCollection(entry.getValue());
}
return size;
}
......
......@@ -535,12 +535,20 @@ public class RosterItem implements Cacheable, Externalizable {
setNickname(item.getName());
}
/*
* (non-Javadoc)
*
* @see org.jivesoftware.util.cache.Cacheable#getCachedSize()
*/
public int getCachedSize() {
int size = jid.toBareJID().length();
size += CacheSizes.sizeOfString(nickname);
size += CacheSizes.sizeOfCollection(groups);
size += CacheSizes.sizeOfCollection(invisibleSharedGroups);
size += CacheSizes.sizeOfCollection(sharedGroups);
size += CacheSizes.sizeOfInt(); // subStatus
size += CacheSizes.sizeOfInt(); // askStatus
size += CacheSizes.sizeOfInt(); // recvStatus
size += CacheSizes.sizeOfLong(); // id
return size;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment