code: public static long sizeOf(Class clazz) {
      long maxSize = headerSize(clazz);
  
      while (clazz != Object.class) {
        for (Field f : clazz.getDeclaredFields()) {
          if ((f.getModifiers() & Modifier.STATIC) == 0) {
            long offset = unsafe.objectFieldOffset(f);
            if (offset > maxSize) {
              // Assume 1 byte of the field width. This is ok as it gets padded out at the end
              maxSize = offset + 1;
            }
          }
        }
        clazz = clazz.getSuperclass();
      }
  
      // The whole class always pads to a 8 bytes boundary, so we round up to 8 bytes.
      return roundUpTo8(maxSize);
    }
docs: Returns the size of an instance of this class (in bytes).
  Instances include a header + all fields + padded to 8 bytes.
  If this is an array, it does not include the size of the elements.
  
  @param clazz
  @return