Open santimar opened 7 years ago
Hi @Aiden01, thanks for the details, this seems like it is related to https://github.com/googleads/googleads-mobile-android-examples/issues/83, we are actively reviewing this issue so we'll update this when we have more info.
Just ran into this in our app.
We use just "basic" Interstitial ads - not "rewarded videos" - directly from Java.
And yes "new InterstitialAd(activity)" does leak the activity instance every time.
The leak is not the callback (and so setting it to null does not help), it's a instance of "bx" (obfuscated name) which in turn holds a "hard" reference to the context.
It seems there are several of these "bx" objects per each InterstitialAd.
@stowy it's been almost a a year since the bug was filed and it's still not fixed:
I tested with ads-lite 12.0.1 using Android Studio memory analyzer.
Leaking Activity objects is bad. They're typically fairly large with a large memory tree - fragments, views, data model, etc. and so this leak can easily cause crashes.
And crashes are bad for users, and also bad for developers because of Android Vitals.
Please seriously consider fixing this as a priority.
thanks for the additional feedback @kmansoft, we are actively working on this and hope to have a fix in an upcoming release. Will advise when the update is scheduled.
is this bug fixed already?
@stowy Any progress on the bug? My interstitials keep leaking my activity
It seems that the interstial is holding a reference to the activity context passed on the constructor, so if you do something like
Your activity gets leaked
The only way i found to avoid this, is to initialize the Interstitial passing application context Same happens with Rewarded video, that you must initialize with
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(getApplicationContext());
instead ofmRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);