Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(backlinks-memory): the corpus-slope check reads the retained heap after a forced GC, not the RSS peak (whose nursery share grows with allocation volume; stress iteration 3 read 25 vs 121 MB with nothing retained); RSS keeps its absolute bound. Forced probe: master's backlinks.ts fails heap 72/288/576 MB

garrytanea308261f67a
diff --git a/test/backlinks-memory.slow.test.ts b/test/backlinks-memory.slow.test.ts
index b859b6f0fe..7ef91427b7 100644
--- a/test/backlinks-memory.slow.test.ts
+++ b/test/backlinks-memory.slow.test.ts
@@ -41,8 +41,12 @@ describe('findBacklinkGaps RSS slope', () => {
expect(r.delta_peak_mb).toBeLessThan(256);
expect(r.heap_retained_mb).toBeLessThan(48);
}
+ // The slope is measured on the heap after a forced GC, which is what the scan kept alive; the RSS peak above
+ // is what the OOM killer sees but also carries JSC's nursery, which grows with allocation volume (a 2.5x to 5x
+ // spread between 48 and 384 MiB with nothing retained), so it holds only the absolute bound. Before the fix the
+ // retained heap was the corpus (48 MiB -> 50 MB, 384 MiB -> 390 MB); after, both sizes keep a few MB.
const largest = runs.at(-1)!;
const smallest = runs[0]!;
- expect(largest.delta_peak_mb).toBeLessThan(smallest.delta_peak_mb * 2 + 64);
+ expect(largest.heap_retained_mb).toBeLessThan(smallest.heap_retained_mb * 2 + 16);
}, 900_000);
});