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

Memory leaks: field c hangs onto a Context reference; and CallbackContext is leaked from within AFKeyStore #199

Open
markproxy opened this issue Mar 4, 2022 · 2 comments

Comments

@markproxy
Copy link

Report

Plugin Version

6.5.2

On what Platform are you having the issue?

android

What did you do?

Used Leak Canary to monitor for leaks in an application that uses this plugin, and found two leaks.

What did you expect to happen?

No leaks

What happened instead?

I tracked down two different leaks:

  • The field c hangs onto a Context reference; this is easily fixed by using a local variable instead
  • I discovered that a class within AppsFlyer lib (AFKeyStore) fails to release its reference to the plugin's AppsFlyerRequestListener, so we need to wrap AppsFlyerRequestListener's reference to CallbackContext in a WeakReference so that it can be garbage-collected, along with its web view and associated activity

Please provide any other relevant information.

I found these leaks in an earlier version of the plugin, but I see in code that they still exist.

@markproxy
Copy link
Author

I have fixes for both of these leaks, and I plan to share them in a PR.

markproxy added a commit to markproxy/appsflyer-cordova-plugin that referenced this issue Mar 4, 2022
- Eliminate field that retains reference to Context
- A class within AppsFlyer lib (AFKeyStore) fails to release its reference to the plugin's AppsFlyerRequestListener, so we need to wrap AppsFlyerRequestListener's reference to CallbackContext in a WeakReference so that it can be garbage-collected, along with its web view and associated activity
- This addresses Issue AppsFlyerSDK#199:
  AppsFlyerSDK#199
@markproxy
Copy link
Author

PR: #200

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