Skip to content

MonetCompatActivity memory leaks #14

Description

@zobnin
  1. MonetCompat is a singleton that stores its own instance in the INSTANCE field. The problem is that MonetCompatActivity creates it by passing itself as context. As a result, when the activity is destroyed, it remains bound to MonetCompat and cannot be released by the garbage collector.

  2. The MonetCompat registers the BroadcastReceiver in the setup method if running on Android 12 or older versions of Android. The MonetCompatActivity calls setup on creation by passing itself to it as context. However, when the activity is destroyed, this BroadcastReceiver is not unregistered, which leads to activity leakage.

For me, the only way to avoid these leaks is to stop using MonetCompatActivity and initialize MonetCompat myself using the application context.

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