Heap Snapshot
This commit is contained in:
@@ -1,6 +1,19 @@
|
|||||||
---
|
---
|
||||||
import { writeHeapSnapshot } from "v8";
|
import { getHeapSnapshot } from "v8";
|
||||||
|
import * as fs from "fs";
|
||||||
|
|
||||||
// Create a named heap snapshot
|
// Create a named heap snapshot
|
||||||
writeHeapSnapshot("~/.heapsnapshot");
|
const snapshotStream = getHeapSnapshot();
|
||||||
|
const fileName = `heap-${Date.now()}.heapsnapshot`;
|
||||||
|
const fileStream = fs.createWriteStream(fileName);
|
||||||
|
|
||||||
|
snapshotStream.pipe(fileStream);
|
||||||
|
|
||||||
|
fileStream.on("finish", () => {
|
||||||
|
console.log(`Heap snapshot saved to ${fileName}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
fileStream.on("error", (err) => {
|
||||||
|
console.error("Error writing heap snapshot:", err);
|
||||||
|
});
|
||||||
---
|
---
|
||||||
Reference in New Issue
Block a user