Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonetCompatActivity memory leaks #14

Open
zobnin opened this issue Aug 17, 2022 · 0 comments
Open

MonetCompatActivity memory leaks #14

zobnin opened this issue Aug 17, 2022 · 0 comments

Comments

@zobnin
Copy link

zobnin commented Aug 17, 2022

  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.

@zobnin zobnin changed the title MonetCompatActivity memory leak MonetCompatActivity memory leaks Aug 20, 2022
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

No branches or pull requests

1 participant