Skip to content

Fix: Add OnDestroy and Subscription sink to prevent memory leaks in core components#82

Open
Anurag-elitx wants to merge 1 commit into
PSMRI:mainfrom
Anurag-elitx:fix/subscription-memory-leaks
Open

Fix: Add OnDestroy and Subscription sink to prevent memory leaks in core components#82
Anurag-elitx wants to merge 1 commit into
PSMRI:mainfrom
Anurag-elitx:fix/subscription-memory-leaks

Conversation

@Anurag-elitx

Copy link
Copy Markdown

Description

Resolved major memory leak vulnerabilities across the application's most heavily used components (case-sheet, beneficiary-registration, and various sio-services). By correctly implementing Angular's OnDestroy lifecycle hook and using a Subscription sink pattern, we ensure that components and their associated data are properly garbage collected when an agent navigates away.

This addresses known performance degradation issues during long-running agent sessions and aligns with best practices for the upcoming Angular 19 migration.

Related to PSMRI/AMRIT#129

Changes Made

  • Imported and implemented OnDestroy interface in critical components.
  • Introduced a subscriptionSink = new Subscription() to pool active subscriptions.
  • Wrapped open .subscribe() calls in this.subscriptionSink.add().
  • Added ngOnDestroy() to tear down subscriptions upon component destruction.

Affected Components

  • CaseSheetComponent
  • BeneficiaryRegistration104Component
  • SioGrievienceServiceComponent
  • SioBloodOnCallServiceComponent
  • SioFoodSafetyServiceComponent

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Anurag-elitx has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 31 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7cdd44e9-e5b8-418f-8c08-a2af790021ba

📥 Commits

Reviewing files that changed from the base of the PR and between df5db19 and 9d576cc.

📒 Files selected for processing (5)
  • src/app/beneficiary-registration-104/beneficiary-registration-104.component.ts
  • src/app/case-sheet/case-sheet.component.ts
  • src/app/sio-blood-on-call-service/sio-blood-on-call-service.component.ts
  • src/app/sio-food-safety-service/sio-food-safety-service.component.ts
  • src/app/sio-grievience-service/sio-grievience-service.component.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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