Skip to content

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

@vibhutomer

Description

@vibhutomer

Description

In document_upload_control.dart, the _DocumentUploadControlState class instantiates a FixedExtentScrollController and a TextEditingController (documentController).

However, the State class entirely lacks a dispose() method. Because these controllers attach to native listeners, failing to dispose of them when the widget is removed from the tree creates a permanent memory leak. In a long-running production environment where operators perform dozens of registrations in a single session, these leaked controllers will compound, eventually exhausting the device's RAM and causing the Android OS to forcefully terminate the application (OOM crash).

Steps to Reproduce

  1. Open the application and navigate to a screen containing the DocumentUploadControl.
  2. Navigate back and forth between this screen and the dashboard multiple times.
  3. Open the Flutter DevTools Memory Profiler.
  4. Observe the memory footprint continuously climbing without garbage collection reclaiming the memory allocated to the TextEditingController and FixedExtentScrollController.

Expected Behavior

All ChangeNotifier objects and controllers must be explicitly disposed of within the State's dispose() lifecycle hook to release native resources and prevent memory leaks.

Environment

  • Target File: lib/ui/process_ui/widgets/document_upload_control.dart

Proposed Solution

Implement the dispose() override in _DocumentUploadControlState and explicitly call .dispose() on both documentController and scrollController.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions