4 Replies Latest reply: Aug 21, 2013 7:28 AM by 1028528 RSS

    How calculate Entry(Key & Value) size in cache?

    1028528

      Guys,

       

      Am seeing two different values when trying to calcuate the size of an Entry(Key a& Value) object in cache, wondering which is correct

      I have <unit-calculator>BINARY</unit-calculator>  and untiFactor =1

       

       

      1.  Using ExternalizableHelper 

      Serializer serializer = cache.getCacheService().getSerializer();

      int entrySize =  ExternalizableHelper.toBinary(tKey, serializer).length() +  ExternalizableHelper.toBinary(tKey, serializer).length() ;

       

      output entrySize = 130bytes

       

       

      2. Querying JMX MBean

      Set<ObjectName> names = mbeanServer.queryNames(new ObjectName("Coherence:type=Cache,service=*,name=" + cacheName + ",*"), null);

       

      long totalUnits = 0;

      for (ObjectName name : names) {

          Integer units = (Integer) mbs.getAttribute(name, "Units");

          Integer unitFactor = (Integer) mbs.getAttribute(name, "UnitFactor");

          Integer size  = (units * unitFactor)/size;

      }

       

      output size = 240bytes..

       

       

      So, wondering why there is huge difference in size returned by ExternalizableHelper and JMX Bean.

      1. Does JMX MBean also add coherence overhead to the the entry size?

      2. Which one is correct method of calcuating the entry size?

       

       

      Thanks

      D