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

Refactor Iap.java: Use WeakReference for Context and Activity to prevent memory leaks #1040

Merged
merged 3 commits into from
Oct 6, 2024

Conversation

ThDev-only
Copy link
Contributor

This PR refactors Iap.java to prevent potential memory leaks by using WeakReference for Context and Activity. This ensures that these references can be garbage collected when necessary, improving memory management.

Changes:

  • Replaced direct Context and Activity usage with WeakReference.
  • Updated methods to access Context and Activity using get() from WeakReference.

Motivation:

Avoid memory leaks in cases where the lifecycle of Context or Activity may extend beyond expected, such as during async callbacks or long-running processes.

…ntext and Activity references

I used the Weak Reference passing the Context and Activity instead of the old Context and Activity directly, this is done to prevent memory leaks and unexpected closure if the context or activity become null
@bajrangCoder bajrangCoder merged commit 49786f6 into deadlyjack:main Oct 6, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants