This discussion is archived
4 Replies Latest reply: Aug 21, 2013 5:28 AM by 82420128-c6b8-49b4-9804-510cbc337b09 RSS

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

82420128-c6b8-49b4-9804-510cbc337b09 Newbie
Currently Being Moderated

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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points