Admob memory leak

1,239 views
Skip to first unread message

Chris

unread,
Sep 18, 2017, 3:32:14 AM9/18/17
to Google Mobile Ads SDK Developers
One of my test devices cause an Activity memory leak when I use admob (Interstitial or Banner). The device is Asus Zenpad C7.0.
The test code is the sample provided by admob.
I found that if I use the Application Context with Interstitial the leak is gone.
My questions are:
- Is it okay to use Application Context with Interstitial?
- Is there any solution to fix the memory leak for Banner?

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Sep 18, 2017, 4:13:02 AM9/18/17
to Google Mobile Ads SDK Developers
Hi Chris,

For the issue about the Interstitial Ads leaking, a similar issue has been reported before and the team is actively investigating the cause of the issue in order to provide a fix. 

However, for the Banner leak, can you provide us some more context? Can you provide us a trace log file as well as the steps to reproduce the leak with our sample apps? Or would it be similar to the Interstitial leak you described?

That said, let me get back to you once I have any updates to share.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

Chris

unread,
Sep 27, 2017, 6:34:28 AM9/27/17
to Google Mobile Ads SDK Developers

The banner leaks the same as the interstitial.

I don't know if it is related with RewardedVideoAd. The interstitial does not have destroy (maybe it should have).
The leaks occur only on some devices and, i believe, all run Android 5 or 5.1 or older.

Here are some tests I have done to look for admob Activity leaks using the basic code.
4.4.2(generic device) - does NOT leak Activity
7.1.2(Nexus 5x) - does NOT leak Activity
5.0.2(Asus ZenPad C 7.0  z170c P01Z) - DOES leak Activity
5.1.1(Samsung SM-G360T) - does NOT leak Activity
5.0.2(Emulator x86) - does NOT leak Activity
4.1.2(Samsung GT-N8013) - DOES leak Activity

My app crashes on some devices, especially on Asus devices, and to investigate the issue I purchased an Asus ZenPad and found that admob leaks Activity on it.
Here are some devices where my app crashes and I believe it has to do with the admob Activity leaks:
Galaxy Note3 (hlte) 599 11.5%
Galaxy S4 (jflte) 455 8.7%
TB3-710F (TB3-710F) 380 7.3%
Galaxy Tab4 10.1 (matissewifi) 259 5.0%
Galaxy Tab4 10.0 (matisselte) 196 3.8%
8080 (Pixi3-10_WiFi) 159 3.1%
Galaxy Grand Prime (grandprimelte) 143 2.7%
VF-1497 (Vodafone_Tab_Prime) 143 2.7%
ZenPad 10 (Z300C) (P023_1) 123 2.4%
One (m7) 117 2.2%
ZenFone 2 (ZE551ML) (Z00A) 113 2.2%
Galaxy S4 (jfvelte) 108 2.1%

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Sep 28, 2017, 2:21:17 AM9/28/17
to Google Mobile Ads SDK Developers
Hi Chris,

Thanks for the informative write-up on this issue. It is interesting to note that you mentioned that they are causing crashes. Would you be able to provide us a minified sample application where the crash can be replicated, the steps to replicate said crash and the complete stack trace of the crash?

Regards,
Joshua Lagonera
Mobile Ads SDK Team

Chris

unread,
Sep 28, 2017, 6:38:16 AM9/28/17
to Google Mobile Ads SDK Developers
The steps to replicate the crash are very complex and can't provide the full source code. I hope that is related to admob leaking Activity and fixing that will fix also the crash.
Theoretically these are the steps:
1.) You need one of the devices that are prone to this crash. (I use Asus Zenpad C 7.0. Most devices won't crash. It seems that it happens only in Android 5 or 5.1)
2.) Load an interstitial video ad(This can be from any advertiser Facebook, moub... And it must be video otherwise there will be no crash later.)
3.) In another Activity load an admob Interstitial ad (The test ad is good enough. This must be admob otherwise there will be no crash later)
4.) At this point my app does some video decoding in background (Nothing is shown on the screen) and at some point the logcat is becoming red while the app is working fine.
I get stuff like:
E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -2147483646
E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!
E/[EGL-ERROR]: void __egl_platform_dequeue_buffer(egl_surface*):1609: failed to dequeue buffer from native window 0x56c8a008;
5.) Later in my app if I attempt to show any other Activity, the app crashes. The crash is dependent on what Activity I show and usually it is android.os.TransactionTooLargeException or java.lang.IllegalStateException
For example if I attempt to show the Interstitial admob ad that was already loaded the crash is:
java.lang.RuntimeException: Unable to start activity ComponentInfo{.../com.google.android.gms.ads.AdActivity}: java.lang.IllegalStateException: Flags.initialize() was not called!
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2702)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1449)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
 Caused by: java.lang.IllegalStateException: Flags.initialize() was not called!
at com.google.android.gms.internal.ahi.a(Unknown Source)
at com.google.android.gms.ads.internal.overlay.ag.g(Unknown Source)
at com.google.android.gms.ads.AdActivity.onStart(Unknown Source)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1234)

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Sep 29, 2017, 1:04:57 AM9/29/17
to Google Mobile Ads SDK Developers
Hi Chris,

This seems to be a different issue from the one you previously reported. However, thank you for providing the detailed crash logs. The stack trace you provided does seem to indicate that it came from the SDK, and it is interesting to note that it only occurs on specific devices. That said, for us to confirm if this is a valid issue of the SDK, we would require a minimal sample project where this crash can be reproduced for us to further investigate the cause of the crash.

If you are not comfortable with providing to us the sample project, then kindly look out for a private email from me and you can provide it there.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Oct 5, 2017, 1:56:45 AM10/5/17
to Google Mobile Ads SDK Developers
Hi Chris,

Hope you are doing well. 

Are you still in need of assistance from our end? If so, then kindly provide us the information we requested on our previous post so we may be able to assist you further. I also sent you an private email in case you would like to provide the requested information privately.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

wen het

unread,
Jan 19, 2018, 4:31:18 AM1/19/18
to Google Mobile Ads SDK Developers
Hi,
    I have noticed that "Admod within Firebase"(com.google.firebase:firebase-ads:11.8.0)  would cause some memory leak problem. In the document, It shows we use "MobileAds.initialize(this,"APPID");" to init "Admob",  When I found It led to memory leaks ,  I changed "this" to "getApplicationContext", It's working good so far,  So would it be ok using "ApplicationContext" here?(sorry for not aware how to edit font background)

Bharani Cherukuri (Mobile Ads SDK Team)

unread,
Jan 19, 2018, 2:18:22 PM1/19/18
to Google Mobile Ads SDK Developers
Hello Wen, 

Thank you for contacting us. Please refrain from reopening old threads and open a new thread for any new concern. That said, it is recommended that you use MobileAds.initialize() method which should be called at the app launch. This class contains the logic to initialize the Mobile Ads SDK on the whole. Please refer to our sample apps for more information. 

Regards,
Bharani, Mobile Ads SDK Team
Reply all
Reply to author
Forward
0 new messages