@Override
        public int getCachedSize() throws CannotCalculateSizeException
        {
            int size = 0;
            size += CacheSizes.sizeOfObject();      // overhead of object
            size += CacheSizes.sizeOfObject();      // overhead of collection.

            // OF-2498: repeated calculation of the true size of each message stanza is very resource intensive.
            //          To avoid performance issues, this implementation uses a size of 2k per message, which has
            //          empirically been observed to be roughly correct. Mileage will probably vary considerably.
            size += history.size() * 2048;

            return size;
        }
A wrapper for a collection of Message instances that is cached.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/HistoryStrategy.java