HeapSnapshotGraph.fromChunks constructor

HeapSnapshotGraph.fromChunks(
  1. List<ByteData> chunks, {
  2. bool calculateReferrers = true,
  3. bool decodeObjectData = true,
  4. bool decodeExternalProperties = true,
  5. bool decodeIdentityHashCodes = true,
})

Populates the HeapSnapshotGraph by parsing the events from the HeapSnapshot stream.

Set flags to false to save processing time and memory footprint by skipping decoding or calculation of certain data:

Implementation

HeapSnapshotGraph.fromChunks(
  List<ByteData> chunks, {
  bool calculateReferrers = true,
  bool decodeObjectData = true,
  bool decodeExternalProperties = true,
  bool decodeIdentityHashCodes = true,
}) {
  final reader = ReadStream(chunks);

  // Skip magic header
  for (int i = 0; i < _magicHeader.length; ++i) {
    reader.readByte();
  }

  _flags = reader.readInteger();

  _name = reader.readUtf8();
  _shallowSize = reader.readInteger();
  _capacity = reader.readInteger();
  _externalSize = reader.readInteger();

  _readClasses(reader);
  _readObjects(reader, decodeObjectData: decodeObjectData);

  if (decodeExternalProperties || decodeIdentityHashCodes) {
    _readExternalProperties(
      reader,
      decodeExternalProperties: decodeExternalProperties,
    );
  }

  if (decodeIdentityHashCodes) {
    _readIdentityHashCodes(reader);
  }

  if (calculateReferrers) _calculateReferrers();
}