gc method

Future<int> gc([
  1. bool nested = false
])

Implementation

Future<int> gc([bool nested = false]) async {
  Iterable<Node> c = nodes.where((i) => !i.$rootNode && !i.$hasReferences);
  List<Future<void>> work = [];

  while (c.isNotEmpty) {
    for (Node n in c.toList()) {
      work.add(removeNode(n.runtimeType, tag: n.$tag));
    }

    await Future.wait(work);
    c = nodes.where((i) => !i.$rootNode && !i.$hasReferences);
  }

  return work.length;
}