{"record":{"id":"ab85ed31068cfd57","repo":"oven-sh/bun","slug":"this-benchmark-needs-a-gc-hook-run-with-bun-or-n","errorCode":null,"errorMessage":"This benchmark needs a GC hook: run with Bun, or node --expose-gc.","messagePattern":"This benchmark needs a GC hook: run with Bun, or node --expose-gc\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bench/snippets/webstreams-memory.mjs","lineNumber":5,"sourceCode":"// Web Streams memory: (1) retained RSS per live instance, (2) peak/settled RSS for\n// streaming workloads. Run with any JS runtime; extra heap counts print under Bun.\nconst N = 100_000;\nconst gc = globalThis.Bun?.gc ?? globalThis.gc;\nif (!gc) throw new Error(\"This benchmark needs a GC hook: run with Bun, or node --expose-gc.\");\nconst rss = () => process.memoryUsage.rss();\nconst MB = 1024 * 1024;\nconst fmt = n => (n / MB).toFixed(1).padStart(8) + \" MB\";\n\nconsole.log(`# per-instance retained RSS (n=${N} live instances)`);\nconst keep = [];\nfunction perInstance(label, make) {\n  gc(true);\n  const before = rss();\n  const held = new Array(N);\n  for (let i = 0; i < N; i++) held[i] = make();\n  gc(true);\n  const perObject = (rss() - before) / N;\n  console.log(`${label.padEnd(40)} ${perObject.toFixed(0).padStart(6)} bytes/instance`);\n  keep.push(held);\n}\nperInstance(\"new ReadableStream({pull(){}})\", () => new ReadableStream({ pull() {} }));\nperInstance(\"new ReadableStream() + getReader()\", () => new ReadableStream({ pull() {} }).getReader());","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/bench/snippets/webstreams-memory.mjs#L1-L23","documentation":"Error \"This benchmark needs a GC hook: run with Bun, or node --expose-gc.\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at bench/snippets/webstreams-memory.mjs:5 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}