googleads / googleads-mobile-android-examples

googleads-mobile-android
Apache License 2.0
1.72k stars 1.87k forks source link

Memory leak in AdMob banner ads contributing to OutOfMemory exceptions #717

Open SimpsOff opened 4 months ago

SimpsOff commented 4 months ago

After noticing our Android apps increased crash rate in Google Play Console, investigations lead to an unexpected number of OOM exceptions. This was mitigated almost completely when we disabled AdMob ads. After some investigations, we added code to capture unhandled exceptions locally, and ran our apps until we received an OOM. I've captured the heapdump from there and converted the hprof file.

Here this is from the MAT tool leak suspects report:

One instance of “com.google.android.gms.ads.nonagon.signalgeneration.k” loaded by “dalvik.system.DelegateLastClassLoader @ 0x13150b10” occupies 41,583,280 (14.37%) bytes. The memory is accumulated in one instance of “java.lang.Object[]”, loaded by “<system class loader>”, which occupies 37,175,312 (12.85%) bytes.

Thread “m.ahy @ 0x12e8d208” has a local variable or reference to “class m.ahy @ 0x131e9870” which is on the shortest path to “java.lang.Object[16384] @ 0x239115e8”. The thread m.ahy @ 0x12e8d208 keeps local variables with total size 528 (0.00%) bytes.

Keywords
com.google.android.gms.ads.nonagon.signalgeneration.k
dalvik.system.DelegateLastClassLoader
java.lang.Object[]

image

To me, it looks like the ArrayDeque is being excessively used, keep around for quite some time, and never cleared, constantly growing over time, eventually leading to OOM crashes if the app lives long enough.

Please fix this leak, as it is preventing me from using google AdMob ads in my app, because we were starting to approach the "Bad Behavior" crash threshold on Google Play due the OOM exceptions being caused (along with another misbehaving ad library).

SimpsOff commented 4 months ago

Please let me know if there are additional diagnostic information that will help get this issue resolved, I will do my best to provide them.

AndroidDeveloperLB commented 4 months ago

This should probably be reported on the google group of Admob, no?

https://groups.google.com/g/google-admob-ads-sdk

NVentimiglia commented 4 months ago

Correct.

Please Report this issue to SDK Support :

https://groups.google.com/g/google-admob-ads-sdk