Skip to content

fix: resolve severe memory leak by disposing controllers in DocumentU…#1062

Open
vibhutomer wants to merge 1 commit into
mosip:masterfrom
vibhutomer:fix/document-control-memory-leak
Open

fix: resolve severe memory leak by disposing controllers in DocumentU…#1062
vibhutomer wants to merge 1 commit into
mosip:masterfrom
vibhutomer:fix/document-control-memory-leak

Conversation

@vibhutomer
Copy link
Copy Markdown

@vibhutomer vibhutomer commented May 14, 2026

Description

This PR resolves a critical memory leak within the document upload workflow that could lead to Out-of-Memory (OOM) application crashes during long operator sessions.

Previously, _DocumentUploadControlState instantiated a TextEditingController and a FixedExtentScrollController but failed to implement a dispose() method. This caused "ghost" controllers to remain active in memory every time the widget was destroyed, compounding RAM usage over multiple registrations until the OS killed the process.

Changes Made

  • Implemented the @override void dispose() lifecycle method in document_upload_control.dart.
  • Explicitly invoked .dispose() on documentController and scrollController to release native memory bindings.

Related Issue

Closes #1061

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance/Stability improvement (Prevents RAM exhaustion)

Checklist

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings or exceptions.

Summary by CodeRabbit

  • Bug Fixes
    • Improved resource management in document upload control to prevent potential memory leaks during widget disposal.

Review Change Stack

…ploadControl

Signed-off-by: vibhutomer <vibhutomer25@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4d8121b1-8642-442e-bfab-e2d746844d59

📥 Commits

Reviewing files that changed from the base of the PR and between aef4fb6 and 8a3366b.

📒 Files selected for processing (1)
  • lib/ui/process_ui/widgets/document_upload_control.dart

Walkthrough

The _DocumentUploadControlState class in document_upload_control.dart now implements a dispose() override that explicitly disposes the documentController and scrollController before calling super.dispose(). This prevents memory leaks that would accumulate when the widget is repeatedly removed from the tree.

Changes

Memory Leak Fix for Document Upload Controllers

Layer / File(s) Summary
Controller resource cleanup in DocumentUploadControl
lib/ui/process_ui/widgets/document_upload_control.dart
The _DocumentUploadControlState class adds a dispose() override that explicitly disposes the documentController and scrollController before invoking super.dispose(), ensuring native listeners are released when the widget leaves the tree.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A leak was lurking, silent and slow,
Controllers undisposed, stealing the flow,
But now with dispose, the resources run free,
Memory flows cleanly, as it should be! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding dispose() method calls to release controller resources and prevent memory leaks in DocumentUploadControl.
Linked Issues check ✅ Passed The pull request fully implements the coding objective from issue #1061: adds dispose() override and explicitly calls .dispose() on both documentController and scrollController.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the memory leak in DocumentUploadControl. No unrelated modifications to other files or functionality were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

Severe Memory Leak leading to Out-Of-Memory (OOM) crashes due to undisposed Controllers

1 participant