Files
online-energieausweis/src/pages/heap-snapshot.astro
Moritz Utcke 5f5e3f4bed Heap Snapshot
2025-06-02 21:49:26 -03:00

19 lines
466 B
Plaintext

---
import { getHeapSnapshot } from "v8";
import * as fs from "fs";
// Create a named heap snapshot
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);
});
---