Skip to content

fix(bindings): stop leaking the state-preload scratch slices - #471

Closed
GrapeBaBa wants to merge 1 commit into
mainfrom
fix/napi-preload-leak
Closed

fix(bindings): stop leaking the state-preload scratch slices#471
GrapeBaBa wants to merge 1 commit into
mainfrom
fix/napi-preload-leak

Conversation

@GrapeBaBa

Copy link
Copy Markdown
Contributor

preloadValidatorsAndBalances discarded the slices returned by getAllReadonlyValues/getAll without freeing them — every call leaked ~240 MB of decoded validator values plus ~16 MB of balances from the global allocator (the TODO's "GC clears it anyway" reasoning does not apply on the Zig side).

  • Free the scratch immediately after the warm-up.
  • Warm the validator view via getAllReadonly (pointers) instead of decoding every validator into values — the cache warming is identical (both routes go through getReadonly) and the scratch drops from ~240 MB to ~16 MB.

Follow-up: once a void prefetchAll lands on the list views (#466), this site can drop the scratch allocation entirely.

preloadValidatorsAndBalances discarded the slices returned by
getAllReadonlyValues/getAll without freeing them — every call leaked
~240 MB of decoded validator values plus ~16 MB of balances from the
global allocator (the TODO's "GC clears it anyway" reasoning does not
apply on the Zig side). Free the scratch immediately, and warm the
validator view via getAllReadonly (pointers) instead of decoding every
validator into values — the cache warming is identical and the scratch
drops from ~240 MB to ~16 MB.
@GrapeBaBa
GrapeBaBa requested a review from a team as a code owner July 7, 2026 14:18
@GrapeBaBa

Copy link
Copy Markdown
Contributor Author

Superseded by #459, which already frees both preload scratch slices. Closing.

@GrapeBaBa GrapeBaBa closed this Jul 7, 2026
@GrapeBaBa
GrapeBaBa deleted the fix/napi-preload-leak branch July 7, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant