public static void main(String[] args) {
    RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
    LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + runtime.getVmVendor()
      + ", vmVersion=" + runtime.getVmVersion());
    LOG.info("vmInputArguments=" + runtime.getInputArguments());
    DefaultMemStore memstore1 = new DefaultMemStore();
    // TODO: x32 vs x64
    final int count = 10000;
    byte[] fam = Bytes.toBytes("col");
    byte[] qf = Bytes.toBytes("umn");
    byte[] empty = new byte[0];
    MemStoreSizing memStoreSizing = new NonThreadSafeMemStoreSizing();
    for (int i = 0; i < count; i++) {
      // Give each its own ts
      memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty), memStoreSizing);
    }
    LOG.info("memstore1 estimated size={}", memStoreSizing.getMemStoreSize().getDataSize()
      + memStoreSizing.getMemStoreSize().getHeapSize());
    for (int i = 0; i < count; i++) {
      memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty), memStoreSizing);
    }
    LOG.info("memstore1 estimated size (2nd loading of same data)={}",
      memStoreSizing.getMemStoreSize().getDataSize()
        + memStoreSizing.getMemStoreSize().getHeapSize());
    // Make a variably sized memstore.
    DefaultMemStore memstore2 = new DefaultMemStore();
    memStoreSizing = new NonThreadSafeMemStoreSizing();
    for (int i = 0; i < count; i++) {
      memstore2.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, new byte[i]), memStoreSizing);
    }
    LOG.info("memstore2 estimated size={}", memStoreSizing.getMemStoreSize().getDataSize()
      + memStoreSizing.getMemStoreSize().getHeapSize());
    final int seconds = 30;
    LOG.info("Waiting " + seconds + " seconds while heap dump is taken");
    LOG.info("Exiting.");
  }
Code to help figure if our approximation of object heap sizes is close enough. See hbase-900.
Fills memstores then waits so user can heap dump and bring up resultant hprof in something like
jprofiler which allows you get 'deep size' on objects.
@param args main args
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultMemStore.java