Skip to content

[ fix ] : fix memory leaks and standardize subscription lifecycle in v0.9#994

Open
Dijo-404 wants to merge 6 commits intogoogle:mainfrom
Dijo-404:fix/963-lifecycle-cleanup
Open

[ fix ] : fix memory leaks and standardize subscription lifecycle in v0.9#994
Dijo-404 wants to merge 6 commits intogoogle:mainfrom
Dijo-404:fix/963-lifecycle-cleanup

Conversation

@Dijo-404
Copy link
Copy Markdown
Contributor

@Dijo-404 Dijo-404 commented Mar 26, 2026

Description

Fixes #963 — Addresses critical memory leaks and standardizes subscription lifecycle management across the A2UI web_core and Angular renderer. This PR prevents unbounded memory growth in long-lived surfaces and eliminates leaked background processes (e.g., timers) when components unmount or properties update.

What's Fixed

  • DataModel.signals cache: Added reference counting to evict unused signal entries and prevent unbounded Map growth.
  • FormatString leaks: Tracked and disposed of all recursive signals created inside format strings (e.g., ${now()}).
  • DataContext unsubscribe chain: Properly propagated unsubscribe ownership for signals returned by function implementations.
  • Angular ComponentBinder scoping: Moved DestroyRef injection to component scope to prevent application-lifetime subscription leaks.
  • Angular stale bindings: Wired up ComponentModel.onUpdated to refresh component properties when the protocol updates them.

Testing

  • Added regression tests verifying AbortSignal listeners and internal Maps are cleared on component unmount.

Verification

  1. Verify Memory Leak Fixes
image 2. Verify Angular Build image

Note

There is an lint error in src/v0_9/catalog/types.test.ts which i haven't touched, its due unused variables, let me know should i fix that and push it in this pr itself or i need to put it as an issue and issue another pr fixing that

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a comprehensive signal lifecycle management system to prevent memory leaks across the Angular, React, and web_core renderers. Key changes include the introduction of signal reference counting in the DataModel, explicit disposal methods for bound properties, and improved cleanup logic for dynamic values and function calls. Feedback suggests simplifying subscription management in the Angular ComponentHostComponent by directly using the subscription object within the cleanup callback to remove unnecessary class properties.

@Dijo-404 Dijo-404 force-pushed the fix/963-lifecycle-cleanup branch from fd2a25c to 4baa44f Compare March 26, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[v0.9] Fix memory leaks and standardize subscription lifecycle in web_core and react renderers

1 participant