Skip to content

[LeakScope] 4 Android lifecycle/memory violations detected #522

@MuhammadTehamsibAliTashfeen

Description

LeakScope: Android Lifecycle & Memory Leak Violations

About this report: This issue was automatically generated by LeakScope, a static analysis tool for Android lifecycle violations and memory leaks built on the Soot framework. This is part of an ongoing academic research study targeting ICSE 2027. No immediate action is required — we would greatly appreciate your feedback on whether these findings are accurate.

Summary

LeakScope detected 4 potential issue(s) across 3 detector type(s):

Severity Count
🔴 High 2
🟡 Medium 1
🟢 Low (improvement opportunity) 1
Detector Count Severity Description
FragmentViewFieldRetentionLeak 2 🔴 High Fragment stores View references in instance fields not cleared in onDestroyView()
ServiceResourceManagementIssueDetector 1 🟡 Medium Service may never stop — missing stopSelf() call
ViewBindingOpportunity 1 🟢 Low Manual findViewById() calls — ViewBinding migration opportunity

Detailed Findings

🔴 FragmentViewFieldRetentionLeak

Fragment stores View references in instance fields not cleared in onDestroyView()

Finding #1BrandingFragment

Fragment View Field Retention Leak Detected
Class: com.parishod.watomatic.fragment.BrandingFragment

Issue:
- Fragment stores View references in instance fields
- These fields are not cleared when the view is destroyed

- onDestroyView() is missing

Leaked Fields:
  • watomaticSubredditBtn : android.widget.Button (assigned in onCreateView)
  • whatsNewBtn : android.widget.Button (assigned in onCreateView)

Why this is dangerous:
- Fragment views are destroyed/recreated on config changes
- Retained View references prevent garbage collection
- Leaked Views hold references to Activity Context
- Can cause OutOfMemoryError with repeated Fragment transactions

Recommended Fix:
Override onDestroyView() and clear all View/Binding fields:
  @Override
  public void onDestroyView() {
    super.onDestroyView();
    watomaticSubredditBtn = null;
    whatsNewBtn = null;
  }

Finding #2MainFragment

Fragment View Field Retention Leak Detected
Class: com.parishod.watomatic.fragment.MainFragment

Issue:
- Fragment stores View references in instance fields
- These fields are not cleared when the view is destroyed

- onDestroyView() is missing

Leaked Fields:
  • mainAutoReplySwitch : com.google.android.material.switchmaterial.SwitchMaterial (assigned in onCreateView)
  • groupReplySwitch : com.google.android.material.switchmaterial.SwitchMaterial (assigned in onCreateView)
  • autoReplyTextPreviewCard : androidx.cardview.widget.CardView (assigned in onCreateView)
  • autoReplyTextPreview : android.widget.TextView (assigned in onCreateView)
  • supportedAppsCard : androidx.cardview.widget.CardView (assigned in onCreateView)
  • timePickerCard : androidx.cardview.widget.CardView (assigned in onCreateView)
  • timePickerSubTitleTextPreview : android.widget.TextView (assigned in onCreateView)
  • timeSelectedTextPreview : android.widget.TextView (assigned in onCreateView)
… (truncated for brevity)

🟡 ServiceResourceManagementIssueDetector

Service may never stop — missing stopSelf() call

Finding #3KeepAliveService

⚠� Service may never stop. Consider calling stopSelf() when work is complete.
  Class: com.parishod.watomatic.service.KeepAliveService
  Method: onStartCommand
⚠� Foreground service started but never removed (missing stopForeground() / stopSelf()).
  Class: com.parishod.watomatic.service.KeepAliveService
  Method: N/A

🟢 ViewBindingOpportunity

Manual findViewById() calls — ViewBinding migration opportunity

Finding #4CustomReplyEditorActivity

View Binding Migration Opportunity
Class: com.parishod.watomatic.activity.customreplyeditor.CustomReplyEditorActivity
Type: Activity
Current Pattern: Manual view lookup
findViewById() Calls:
  • findViewById in onCreate
  • findViewById in onCreate
  • findViewById in onCreate
Benefits of View Binding:
- Eliminates boilerplate findViewById() calls
- Compile-time type safety for view references
- Reduced null pointer exceptions
- Cleaner, more maintainable code
Note: This is a code modernization suggestion, not a memory leak

How to respond to this issue:

  • If a finding is a true positive: consider applying the recommended fix and closing this issue.
  • If a finding is a false positive: please leave a comment explaining why — your feedback directly improves our research.
  • If you have questions: reply here or open a discussion.

This report was generated by LeakScope as part of the ICSE 2027 research artifact. Tool analyzes compiled APKs using Soot static analysis on watomatic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions