code: private static long getObjectSize(Object obj, boolean isArray, Instrumentation instr) {
      if (isArray) {
        return instr.getObjectSize(obj);
      }
  
      Class<?> clazz = obj.getClass();
      Long classSize = classSizesMap.get(clazz);
      if (classSize == null) {
        classSize = instr.getObjectSize(obj);
        classSizesMap.put(clazz, classSize);
      }
  
      return classSize;
    }
docs: Returns the size of the given object. If the object is not an array, we check the cache first,
  and update it as necessary.
  
  @param obj the object.
  @param isArray indicates if the given object is an array.
  @param instr the instrumentation object to use for finding the object size
  @return the size of the given object.