static long safeSizeof(Class<?> clazz) {
    // This code is not as accurate as unsafe but gives an estimate of memory used.
    // If it is wrong it will always underestimate because it does not account
    // for any of the field alignment that the jvm does.
    long size = OBJECT_SIZE;
    do {
      Field[] fields = clazz.getDeclaredFields();
      for (Field field : fields) {
        if (!Modifier.isStatic(field.getModifiers())) {
          size += sizeType(field.getType());
        }
      }
      clazz = clazz.getSuperclass();
    } while (clazz != null);
    return size;
  }
Returns -1 if it was not able to compute the size; otherwise returns the size.
Since unsafe.fieldOffset(Field) will give us the offset to the first byte of that field all we
need to do is find which of the non-static declared fields has the greatest offset.
geode-core/src/main/java/org/apache/geode/internal/size/ReflectionSingleObjectSizer.java