Skip to content

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 Acode-Foundation: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