public static void recordAllocation(Class<?> cls, Object newObj) {
    // The use of replace makes calls to this method relatively ridiculously
    // expensive.
    String typename = cls.getName().replace('.', '/');
    recordAllocation(-1, typename, newObj);
  }
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.
src/main/java/com/google/monitoring/runtime/instrumentation/AllocationRecorder.java