addObject<E> method

void addObject<E>(
  1. E value, {
  2. required Kind? kind,
})

Adds memory needed by reference to value and the object itself (unless it has been visited already).

If kind is not given, it is inferred from value.

Implementation

void addObject<E>(E value, {required Kind? kind}) {
  kind ??= Kind.find(instance: value);
  _sum += 8;
  if (value == null || value is bool || value is num || !_set.add(value)) {
    return;
  }
  kind.memorySizeWith(this, value);
}