autoRelease method

void autoRelease(
  1. List<Releasable?> instances
)
inherited

The autoRelease method is used to register a set of Releasable instances that will be automatically released when this instance becomes unreachable. Please note that this mechanism is based on Dart's Finalizer feature which makes no guarantee that it will ever be called. Depending on instance dependencies and their relationship with the internal Finalizer instance, it may even never be called. For instance, make sure this is never passed to autoRelease as this will create a cyclic graph of dependencies that will prevent finalization to happen.

Implementation

void autoRelease(List<Releasable?> instances) {
  for (var instance in instances.whereType<Releasable>()) {
    print('tag $instance for auto-release');
    _finalizer.attach(_token, instance, detach: _token);
  }
}