Skip to content

fix(rust): count each live string allocation toward max_heap_bytes - #111

Closed
brxs wants to merge 1 commit into
anomalyco:devfrom
brxs:fix/heap-limit-strings-and-bigint
Closed

brxs wants to merge 1 commit into
anomalyco:devfrom
brxs:fix/heap-limit-strings-and-bigint

Conversation

@brxs

@brxs brxs commented Nov 27, 2026 •

Copy link
Copy Markdown

Fixes #109.

Summary

Counts each distinct live string allocation (StrId) toward Limits::max_heap_bytes instead of deduplicating by string text content.

Changes

  • heap.rs: Remove Walk::texts content-based deduplication so Walk::string charges STRING_BYTES + 2 * len16() once per reachable StrId (tracked by Walk::strings: Vec<bool>). Shared references to the same string (e.g. new Array(1000).fill(s) or static/single-char strings) still count once, while separately allocated identical buffers (e.g. repeated 'x'.repeat(10_000)) each count their own allocation.
  • tests/heap.rs: Add duplicate_fresh_strings_count_each_allocation regression test.

Verification

  • cargo fmt --check
  • cargo clippy --offline --locked -p psychoscript --all-targets -- -D warnings
  • cargo test --offline --locked -p psychoscript --test heap (12/12 passed)
  • PSYCHOSCRIPT_GC_STRESS=1 cargo test --offline --locked -p psychoscript --test heap (12/12 passed)

@brxs brxs closed this Nov 27, 2026
@brxs
brxs deleted the fix/heap-limit-strings-and-bigint branch November 27, 2026 19:34
@brxs brxs changed the title fix(rust): count each live string allocation and heap BigInt toward max_heap_bytes fix(rust): count each live string allocation toward max_heap_bytes Nov 27, 2026
@brxs

brxs commented Nov 27, 2026

Copy link
Copy Markdown
Author

Split into two smaller focused PRs: #115 (duplicate fresh strings, fixes #109) and #114 (heap BigInts, fixes #113).

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.

fix(rust): duplicate fresh strings bypass Limits::max_heap_bytes

2 participants