docs(native-chat): describe held live-text bytes as an estimate

This commit is contained in:
Brennan Benson
2026-11-18 10:36:30 -08:00
parent 574a90c268
commit df0eda69e8
@@ -25,9 +25,10 @@ const VALUE_BYTES = 16
const sizes = new WeakMap<object, number>()
/**
* What a payload holds on the heap, from above for its strings: two bytes per character, plus a
* fixed cost per value. One visit per value and no serialization, so a growing reply costs its
* value count, not its text length; measured once per payload however many holders share it.
* Estimates what a payload holds on the heap: two bytes per character plus a fixed cost per value.
* One visit per value and no serialization, so a growing reply costs its value count, not its
* length; measured once per payload however many holders share it. A string sliced from a larger
* one would keep more alive, but live text is parsed provider output, never such a slice.
*/
export function heldBytesOf(payload: object): number {
const cached = sizes.get(payload)