@Override
  public long heapSize() {
    // Deep object overhead for this KV consists of two parts. The first part is the KV object
    // itself, while the second part is the backing byte[]. We will only count the array overhead
    // from the byte[] only if this is the first KV in there.
    int fixed = ClassSize.align(FIXED_OVERHEAD);
    if (offset == 0) {
      // count both length and object overhead
      return fixed + ClassSize.sizeOfByteArray(length);
    } else {
      // only count the number of bytes
      return (long) fixed + length;
    }
  }
HeapSize implementation
<p/>
We do not count the bytes in the rowCache because it should be empty for a KeyValue in the
MemStore.
hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java