Skip to content

feat(runtime): configurable garbage collector, memory leak fix, regression test#1248

Open
zaccharyfavere wants to merge 1 commit into
SkipLabs:mainfrom
zaccharyfavere:gc-config-and-leak-fix
Open

feat(runtime): configurable garbage collector, memory leak fix, regression test#1248
zaccharyfavere wants to merge 1 commit into
SkipLabs:mainfrom
zaccharyfavere:gc-config-and-leak-fix

Conversation

@zaccharyfavere

@zaccharyfavere zaccharyfavere commented May 27, 2026

Copy link
Copy Markdown
Contributor

Adds a configurable GC sweep mechanism for orphan reactive resources, exposes Skip persistent memory (from palloc.c) usage as a metric, fixes a separate memory leak in the reactive read tracking, and ships a regression test that detects future memory leaks.

GC configuration

  • gcConfig lambda on SkipService, read each sweep via the
    SkipRuntime_callGCConfigProvider FFI bridge so the config can react to the
    environment in real time
  • fields: enabled, ttlMillis, maxGarbageSize, logsEnabled
  • defaults change: maxGarbageSize now caps the queue at 100 (previously
    unbounded, TTL-only). Services that don't provide gcConfig get this cap.
  • negative ttlMillis or maxGarbageSize disables the corresponding eviction
    criterion (never expires / unbounded)

Memory leak fix

  • Context.reads is cleared at the end of each sweep; reads accumulated
    indefinitely otherwise, leaking memory.

Metrics and tooling

  • getSkipPersistentSize exposed through the FFI chain as the memory metric
  • stress test (gc-stress.ts) with a linear-regression slope check
  • Makefile test-mem-stress target

Notes

  • the instantiate-close-with-map sub-test fails on this branch alone;
    it requires the fix-deleteddir-leak PR for the DeletedDir cleanup, and
    passes once both are merged.
    Therefore, the stress test (gc-stress.ts) isn't automatically called by
    the CI yet because it would fail. I'll follow up to add that.

@zaccharyfavere zaccharyfavere force-pushed the gc-config-and-leak-fix branch 2 times, most recently from 4d54c4d to 87ae2cf Compare May 28, 2026 14:34
@mbouaziz mbouaziz requested a review from skiplabsdaniel May 28, 2026 14:36
@zaccharyfavere zaccharyfavere force-pushed the gc-config-and-leak-fix branch 3 times, most recently from bd1c802 to f6071d4 Compare June 4, 2026 10:32
@zaccharyfavere zaccharyfavere force-pushed the gc-config-and-leak-fix branch 3 times, most recently from 4462a31 to f9fb606 Compare June 24, 2026 11:08
@zaccharyfavere zaccharyfavere force-pushed the gc-config-and-leak-fix branch 2 times, most recently from 0b52b3b to 5dfb112 Compare June 26, 2026 08:59
GC configuration
- gcConfig lambda on SkipService, read each sweep via the
  SkipRuntime_callGCConfigProvider FFI bridge so the config can react to the
  environment in real time
- fields: enabled, ttlMillis, maxGarbageSize, logsEnabled
- defaults change: maxGarbageSize now caps the queue at 100 (previously
  unbounded, TTL-only). Services that don't provide gcConfig get this cap.
- negative ttlMillis or maxGarbageSize disables the corresponding eviction
  criterion (never expires / unbounded)

Memory leak fix
- Context.reads is cleared at the end of each sweep; reads accumulated
  indefinitely otherwise, leaking memory.

Metrics and tooling
- getSkipPersistentSize exposed through the FFI chain as the memory metric
- stress test (gc-stress.ts) with a linear-regression slope check
- Makefile test-mem-stress target

Notes
- the instantiate-close-with-map sub-test fails on this branch alone;
it requires the fix-deleteddir-leak PR for the DeletedDir cleanup, and
passes once both are merged.
Therefore, the stress test (gc-stress.ts) isn't automatically called by
the CI yet because it would fail. I'll follow up to add that.
@zaccharyfavere zaccharyfavere force-pushed the gc-config-and-leak-fix branch from 5dfb112 to 3ec9344 Compare June 26, 2026 09:19
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