Skip to main content

Function: anonymizeHeapSnapshotFile()

anonymizeHeapSnapshotFile(inputFile, outputFile, options?, onProgress?): Promise\<AnonymizeReport>

Defined in: core/src/lib/HeapAnonymizer.ts:905

Anonymize a .heapsnapshot file and write the result to another file.

The file-to-file form of anonymizeHeapSnapshot, and the one to reach for when the capture is only being shared rather than analyzed here: it skips building the object graph on the way in, and streams on the way out, so neither the input nor the output is ever held as one string.

Parameters

inputFile

string

absolute path of the capture to read

outputFile

string

absolute path to write the anonymized capture to; an existing file at that path is overwritten

options?

AnonymizeOptions = {}

see AnonymizeOptions

onProgress?

AnonymizeProgressCallback

Returns

Promise\<AnonymizeReport>

a summary of what was redacted, and what was left in the clear; see AnonymizeReport

  • Examples:
import {anonymizeHeapSnapshotFile} from '@memlab/core';

(async function () {
const report = await anonymizeHeapSnapshotFile(
'/tmp/capture.heapsnapshot',
'/tmp/shareable.heapsnapshot',
);
console.log(`redacted ${report.valuesRedacted} string values`);
for (const family of report.unclassifiedLabelFamilies) {
console.log(`still in the clear: ${family.count} x ${family.shape}`);
}
})();