Skip to content

Prune dead observers on registration#751

Open
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3a-prune-observers
Open

Prune dead observers on registration#751
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3a-prune-observers

Conversation

@wdcui
Copy link
Copy Markdown
Member

@wdcui wdcui commented Apr 7, 2026

Summary

  • Prune stale Weak references from the observer list every time a new observer is registered, preventing unbounded growth when observers are dropped without explicit removal.
  • Add register_observer_prunes_dead_entries unit test to verify GC behavior.

Split from #743.

Add prune_dead_observers() to Subject, called during register_observer()
to eagerly clean up stale weak references. Previously dead observers were
only cleaned up during notify_observers(), which could leave orphaned
entries indefinitely if notifications were infrequent.

Includes a test verifying that registering a new observer prunes stale
entries from a previously dropped observer.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🤖 SemverChecks 🤖 No breaking API changes detected

Note: this does not mean API is unchanged, or even that there are no breaking changes; simply, none of the detections triggered.

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