lib/third_party/tracing/model/global_memory_dump.js
function(fn) {
      var visitedDumps = new WeakSet();
      var openDumps = new WeakSet();

      function visit(dump) {
        if (visitedDumps.has(dump))
          return;

        if (openDumps.has(dump))
          throw new Error(dump.userFriendlyName + ' contains a cycle');
        openDumps.add(dump);

        // Visit owners before the dumps they own.
        dump.ownedBy.forEach(function(ownershipLink) {
          visit.call(this, ownershipLink.source);
        }, this);

        // Visit children before parents.
        dump.children.forEach(visit, this);

        // Actually visit the current memory allocator dump.
        fn.call(this, dump);
        visitedDumps.add(dump);

        openDumps.delete(dump);
      }

      this.iterateAllRootAllocatorDumps(visit);
    }
function(fn) {
      var visitedDumps = new WeakSet();
      var openDumps = new WeakSet();

      function visit(dump) {
        if (visitedDumps.has(dump))
          return;

        if (openDumps.has(dump))
          throw new Error(dump.userFriendlyName + ' contains a cycle');
        openDumps.add(dump);

        // Visit owners before the dumps they own.
        dump.ownedBy.forEach(function(ownershipLink) {
          visit.call(this, ownershipLink.source);
        }, this);

        // Visit children before parents.
        dump.children.forEach(visit, this);

        // Actually visit the current memory allocator dump.
        fn.call(this, dump);
        visitedDumps.add(dump);

        openDumps.delete(dump);
      }

      this.iterateAllRootAllocatorDumps(visit);
    }
function ( fn ) { var visitedDumps = new WeakSet ( ) ; var openDumps = new WeakSet ( ) ; function visit ( dump ) { if ( visitedDumps . has ( dump ) ) return ; if ( openDumps . has ( dump ) ) throw new Error ( dump . userFriendlyName + ' contains a cycle' ) ; openDumps . add ( dump ) ; // Visit owners before the dumps they own. dump . ownedBy . forEach ( function ( ownershipLink ) { visit . call ( this , ownershipLink . source ) ; } , this ) ; // Visit children before parents. dump . children . forEach ( visit , this ) ; // Actually visit the current memory allocator dump. fn . call ( this , dump ) ; visitedDumps . add ( dump ) ; openDumps . delete ( dump ) ; } this . iterateAllRootAllocatorDumps ( visit ) ; }
Traverse the memory dump graph in a depth first post-order, i.e.
children and owners of a memory allocator dump are visited before the
dump itself. This method will throw an exception if the graph contains
a cycle.
Traverse the memory dump graph in a depth first post - order i . e . children and owners of a memory allocator dump are visited before the dump itself . This method will throw an exception if the graph contains a cycle .